I'm using the built-in geolocation functions in /engine/lib/location.php to search for entities within a radius. I think I've formatted the function call correctly, but I get a database error when it runs.
I do have the geolocation module installed and enabled with a Google Maps API key. Here's what I'm doing in my module:
$geocode = elgg_geocode_location($location);
$nearby = get_entities_in_area($geocode['lat'], $geocode['long'], 20 * MILE, 'object', 'checkpoint');
elgg_geocode_location() does return a valid coordinate pair for its input, but the second instruction results in a database exception. If I comment out the second instruction, the error doesn't occur.
Has anyone seen anything like this before, or can someone testify that they have successfully used this function so I can be sure it's my error and not a bug in Elgg?
This is the database exception information that comes up when I load the page:
Unknown column 'n.calendar_start' in 'order clause'
QUERY: SELECT e.* from elgg_entities e
JOIN elgg_metadata loc_start on e.guid=loc_start.entity_guid
JOIN elgg_metastrings loc_start_name on loc_start.name_id=loc_start_name.id
JOIN elgg_metastrings loc_start_value on loc_start.value_id=loc_start_value.id
JOIN elgg_metadata loc_end on e.guid=loc_end.entity_guid
JOIN elgg_metastrings loc_end_name on loc_end.name_id=loc_end_name.id
JOIN elgg_metastrings loc_end_value on loc_end.value_id=loc_end_value.id
where e.type='object' and e.subtype=5 and e.site_guid = 1 and loc_start_name.string='geo:lat' and loc_start_value.string>=40.3080589 and loc_start_value.string<=40.9140589 and loc_end_name.string='geo:long' and loc_end_value.string >= -112.2029353 and loc_end_value.string <= -111.5969353 and ( (1 = 1) and e.enabled='yes') order by n.calendar_start limit 0, 10
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Mike Zacher (vazco)@vazco
Mike Zacher (vazco) - 0 likes
You must log in to post replies.You may check vazco_gmap plugin, I think the GPL version contains function that searches by radius.