I have a Google Maps and I get all markers that are close to a
location (lat, lng). This point is OK.
Now i want to sort theses markers, like in SQL we can do a "order by
distance ASC" for example.
I saw in javascript have a method call sort() which can sort some
numbers asc or desc for example.
markers have some informations: name, title, gender, city,
postcode ...
my code:
var nbMeters = 50000;
for (var i = 0; i < markers.length; i++) {
var myMarker = markers[i];
coord2 = new google.maps.LatLng(myMarker.lat, myMarker.lng);
var distance =
google.maps.geometry.spherical.computeDistanceBetween(coords,
coords2);
if(distance <= nbMeters) {
alert(myMarker.name);
//OK my marker is close the variable coords, good !
//But how to know which marker is the closer, which is the second,
the third ... and the less closer ??
}
}
Have you an idea?
Thanks
--
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.