Update to version v3. The library is declared as follows:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&v=3&libraries=geometry"></script>
Finding the distance as follows:
var loc1 = google.maps.LatLng(52.5773139, 1.3712427); var loc2 = google.maps.LatLng(52.4788314, 1.7577444); alert(google.maps.geometry.spherical.computeDistanceBetween (loc1, loc2));
Firebug returns this:
TypeError: a is undefined
Assuming this is an error, because lat and lon should be passed as objects, so after some searches I tried this:
var loc1 = google.maps.LatLng({'position' :52.5773139, 1.3712427}); var loc2 = google.maps.LatLng({'position' :52.4788314, 1.7577444});
Still getting the same error that I am doing wrong?
source share