Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Using Geocoder as a stand-alone function

 

 


rcrofoot
User

Aug 5, 2011, 4:22 PM

Post #1 of 2 (1363 views)
Shortcut
Using Geocoder as a stand-alone function Can't Post

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


Jason
Staff / Moderator


Aug 8, 2011, 9:51 AM

Post #2 of 2 (1151 views)
Shortcut
Re: [rcrofoot] Using Geocoder as a stand-alone function [In reply to] Can't Post

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:


Code
 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 - Programmer 
interactivetools.com

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