Using Geocoder as a stand-alone function
2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 8, 2011 (RSS)
By rcrofoot - August 5, 2011
Hello -
I'd like to use the functionality of your geocoder "Sample form with automatic geocoding", but without the form, but am a little confused as to how to do this...
Ideally, I would set up a function that accepts an address (or zip code), and have the function return the lat/long values...
I suspect there's a way to use the geocoder to do this with PHP and without the form...Any help appreciated!
Thanks, Rick
I'd like to use the functionality of your geocoder "Sample form with automatic geocoding", but without the form, but am a little confused as to how to do this...
Ideally, I would set up a function that accepts an address (or zip code), and have the function return the lat/long values...
I suspect there's a way to use the geocoder to do this with PHP and without the form...Any help appreciated!
Thanks, Rick
Re: [rcrofoot] Using Geocoder as a stand-alone function
By Jason - August 8, 2011
Hi Rick,
Yes, you can do this by calling the geocodeAddress() function directly. This function takes in an address (this can be a full address or a partial, ie zip code) and attempts to return the latitude and longitude of that address. The more information you have in your address, the more accurate your latitude and longitude is.
Here's an example of how you would call the function:
In this example, $address contains the address you want to geocode. at the end of the code, the lat and long of the address will be stored in $latitude and $longitude.
Hope this helps
Yes, you can do this by calling the geocodeAddress() function directly. This function takes in an address (this can be a full address or a partial, ie zip code) and attempts to return the latitude and longitude of that address. The more information you have in your address, the more accurate your latitude and longitude is.
Here's an example of how you would call the function:
list ($latitude, $longitude) = geocodeAddress($address);
In this example, $address contains the address you want to geocode. at the end of the code, the lat and long of the address will be stored in $latitude and $longitude.
Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/