You can also extend the functionality yourself like this:
google.maps.LatLng.prototype.distanceFrom = function(newLatLng) {
var lat1 = this.lat() * Math.PI / 180.0;
var lat2 = newLatLng.lat() * Math.PI / 180.0;
var lngDiff = (newLatLng.lng() - this.lng()) * Math.PI / 180.0;
return Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) *
Math.cos(lat2) * Math.cos(lngDiff)) * 20902231.0029;
};
that will add the ability to do a roughly correct spherically adjusted
distance. Any LatLng object can then be used thusly:
var distance = LatLng1.distanceFrom(LatLng2);
I believe this particular equation gives a distance in feet.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.