Done some Google Mpas stuff by myself, but stopped on distance calculating. I have a function for locating users current location marker:
function myLocationMarker(latLng) {
var markerOptions = {
position: latLng,
map: map,
clickable: true
}
var myMarker = new MarkerWithLabel(markerOptions);
And this function places other markers. I get the data from database, and it places about 1000 markers.
var markers = []; //blank array from markers
function addMarker(lat, lng, info) { //info - needed for database
var pt = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({ //marker options
position: pt,
icon: icon,
map: map
});
markers.push(marker); //pushing every marker to markers array
But what I need is distance between them.
How I can calculate distance between myLocationMarker
and every other marker on map from addMarker
function?