The Google Maps API v3 spherical geometry library has a method:
computeDistanceBetween(from:LatLng, to:LatLng) - number - Returns the distance between two LatLngs.
Which returns the distance between two LatLng objects in meters.
(not tested)
var closeDistance = 111000; // 111 km
function showPlaceCloseBy(lat,lng){
var myLocation = new google.maps.LatLng(lat, lng);
closePins = [];
for (var i=0; i < pins.length; i++) {
// HERE WE FIND WHETHER THE PLACE IS CLOSE ENOUGH
if (calculateDistanceBetween(myLocation, pins[i].getPosition()) < closeDistance)
{
closePins.push(pins[i]);
}
}
return closePins;
}
// Note: do not use undocumented properties like .hb, .ib; they can and do change.
var calcLat= myLat-pinToCompare.position.hb; // IS THIS RIGHT?
var calcLong = myLng-pinToCompare.position.ib; // IS THIS RIGHT?