GLatLng is the API's basic location object, it's a 'thing' not a function. It does come with built-in methods to operate on the location, such as .distanceFrom()
geocoder.getLatLng() is method that returns you some data, that data is ready-structured as a GLatLng object for you by the API. As a GLatLng object, it has the distanceFrom() method built-in. Note that return of the data is asynchronous because of the round-trip to Google and back. http://econym.org.uk/gmap/async.htm Note that if you have only one geocoder object, and start re-using it before the previous result comes back, things will go wrong. Some structure like this should work (untested) - geocoder.getLatLng(from,function(from_gl) { if (!from_gl) { alert(from + " not found"); } else { geocoder.getLatLng(to,function(to_gl) { if (!to_gl) { alert(to + " not found"); } else { alert(to_gl.distanceFrom (from_gl)); } } } } As soon as you do more than one geocode at a time, you may run into the issues described here - http://econym.org.uk/gmap/geomulti.htm Error checking any geocode request is probably a good idea http://econym.org.uk/gmap/geo.htm but that would preclude simple use of geocoder.getLatLng cheers, Ross K --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
