de Brad
google.maps.geometry.spherical.computeArea(yourPolygon.getPath());
es correcto, pero ten cuidado, solo se aplica a los polígonos que no se intersecan por sí mismos. Cuando el polígono comienza a autointersecarse, las cosas van horriblemente mal. Puede intentarlo con el enlace Brad dio http://geojason.info/demos/line-length-polygon-area-google-maps-v3/. Simplemente dibuja 4-5 líneas que se intersectan y comienza a jugar con los vértices. El cálculo del área definitivamente parecerá incorrecto.
Si usted no está convencido, aquí hay un ejemplo:
var map;
google.maps.visualRefresh = true;
google.maps.event.addDomListener(window, 'load', initialize);
function initialize() {
var mapOptions = {
center : new google.maps.LatLng(55.874, -4.287),
zoom : 16,
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions)
drawExample();
}
function drawExample() {
var pathLeft = [new google.maps.LatLng(55.874, -4.292),
new google.maps.LatLng(55.875, -4.292),
new google.maps.LatLng(55.875, -4.290),
new google.maps.LatLng(55.876, -4.290),
new google.maps.LatLng(55.876, -4.291),
new google.maps.LatLng(55.874, -4.291)]
var polygonLeft = new google.maps.Polygon({
path : pathLeft,
map: map
});
var areaLeft = google.maps.geometry.spherical.computeArea(polygonLeft.getPath());
var pathRight = [new google.maps.LatLng(55.874, -4.282),
new google.maps.LatLng(55.875, -4.282),
new google.maps.LatLng(55.875, -4.280),
new google.maps.LatLng(55.8753, -4.2807),
new google.maps.LatLng(55.876, -4.281),
new google.maps.LatLng(55.874, -4.281)]
var polygonRight = new google.maps.Polygon({
path : pathRight,
map: map
});
var areaRight = google.maps.geometry.spherical.computeArea(polygonRight.getPath());
console.log("areaLeft: " + areaLeft + "\nareaRight: " + areaRight);
}
El informe de error http://code.google.com/p/gmaps-api-issues/issues/detail?id=5624&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal&start=700#makechanges
esta API se tome en cuenta la elevación de la tierra ?. Obtendré las coordenadas de un dispositivo GPS. –
No, supone una tierra esférica perfectamente lisa. Parece que lo que realmente quieres es el área de superficie de un modelo de elevación digital. Esto se puede calcular mediante la función r.surf.area en GRASS GIS, pero si quiere saber más, probablemente debería preguntar en gis.stackexchange.com – Spacedman
@Spacedman: ¿Puede Grass GIS integrarse con Google Maps? –