Aquí es una función de JavaScript simple que puede ser útil a partir de este link .. relacionados de alguna manera, pero estamos usando Google Earth Plugin javascript en lugar de mapas
function getApproximateDistanceUnits(point1, point2) {
var xs = 0;
var ys = 0;
xs = point2.getX() - point1.getX();
xs = xs * xs;
ys = point2.getY() - point1.getY();
ys = ys * ys;
return Math.sqrt(xs + ys);
}
Las unidades Tho no están en la distancia, pero en términos de una relación relativa a tus coordenadas.Hay otros cálculos relacionados que pueden sustituir a los getApproximateDistanceUnits funcionan link here
Entonces utilizar esta función para ver si una latitud y longitud se encuentra dentro del radio de
function isMapPlacemarkInRadius(point1, point2, radi) {
if (point1 && point2) {
return getApproximateDistanceUnits(point1, point2) <= radi;
} else {
return 0;
}
}
punto puede definirse como
$$.getPoint = function(lati, longi) {
var location = {
x: 0,
y: 0,
getX: function() { return location.x; },
getY: function() { return location.y; }
};
location.x = lati;
location.y = longi;
return location;
};
luego puede hacer lo suyo para ver si un punto está dentro de una región con un radio decir:
//put it on the map if within the range of a specified radi assuming 100,000,000 units
var iconpoint = Map.getPoint(pp.latitude, pp.longitude);
var centerpoint = Map.getPoint(Settings.CenterLatitude, Settings.CenterLongitude);
//approx ~200 units to show only half of the globe from the default center radius
if (isMapPlacemarkInRadius(centerpoint, iconpoint, 120)) {
addPlacemark(pp.latitude, pp.longitude, pp.name);
}
else {
otherSidePlacemarks.push({
latitude: pp.latitude,
longitude: pp.longitude,
name: pp.name
});
}
Para una mayor precisión - ver https://stackoverflow.com/questions/1420045/how-to-find-distance-from-the -latitud-y-longitud-de-dos-ubicaciones/1422562 # 1422562 –