I am currently working on calculating distances between two points, but I keep getting an error that says Uncaught TypeError: a.lat is not a function.
function MapLocations() {
var i = 0;
var infoWindow = new google.maps.InfoWindow();
var myLatLng = {lat: 31.553761202565646, lng: 74.26506623625755}
var m = new google.maps.Marker({
map: map,
clickable: true,
animation: google.maps.Animation.DROP,
title: 'My Home',
position: myLatLng,
// html: h[i],
});
var circle = new google.maps.Circle({
map: map,
radius: 18.288, // 10 miles in metres
fillColor: '#50D050'
});
circle.bindTo('center', m, 'position');
var distanceInMetres = google.maps.geometry.spherical.computeDistanceBetween(myLatLng, pos).toFixed(2);
//console.log(distanceInMetres);
//google.maps.event.addListener(m, 'click', function () {
// infoWindow.setContent('Hello');
// infoWindow.open(map, this);
//});
//google.maps.event.addListener(dragable_marker, 'dragend', function (e) {
// alert(circle.getBounds().contains(dragable_marker.getPosition()));
//});
//alert(distanceInMetres);
i++;
}
The user's position (pos) is retrieved from the navigator object. Everything works fine until I remove the computeDistance function.