GeoCoder URL Query

6 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 5, 2012   (RSS)

Dear Support Team,

How can I do a url/search query to show listing within specific parameters?

IE show events within 50miles... 25miles... etc

Thanks

Re: [Damon] GeoCoder URL Query

Hi Damon,

Thanks for the prompt reply. I have a sample page setup here: http://www.illumemagazine.com/indulge/xxx.php

What would I use as the url query to show a list of places nearby (no radius limit)..starting with closest to farthest?

Many thanks for your help.

Re: [Illume Magazine] GeoCoder URL Query

By Jason - June 4, 2012

Hi,

So you are trying to retrieve a list of records near the current record. Is that right? If so, you can try a modification of the searching code.

for example (NOTE: this code is untested):

// get geocoding data
list($myLat, $myLng) = geocodeAddress( $record['address'] );
$kmOrMiles = 'miles'; // can be 'miles' or 'km'
$geoOptions = geocoder_getOptions($myLat, $myLng, "100", $kmOrMiles);

// get records
list($addressRecords, $addressMetaData) = getRecords(array(
'tableName' => $GLOBALS['GEOCODER_SAMPLE_TABLENAME'],
'where' => "num != '".intval($record['num'])."'",
) + $geoOptions); // geoOptions WILL NOT override the above options


In this example, we start by geocoding the current record ($record) and setting a radius of 100 miles.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] GeoCoder URL Query

Hi Jason,

Thanks for the quick reply. What if I want to implement this code on a mobile device or website that pull user geolocation? How can I insert the user location into the code and then show a list based on a 100 mile radius?

Re: [Illume Magazine] GeoCoder URL Query

By Jason - June 5, 2012

Hi,

There will be a couple of options for you for doing this. Basically, you need to pull the lat/long of the current user (accuracy will vary depending on location). You can either do this on the server side, by querying a 3rd party API to get coordinates based on an IP address (see here http://stackoverflow.com/questions/7766978/geo-location-based-on-ip-address-php)

or you can use javascript on the browser to try to determine the location and use jquery to update your list of "nearby results" (see here: http://en.wikipedia.org/wiki/W3C_Geolocation_API). Your ability to use this second option will depend on the browser being used to at the time.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/