ブラッドの答え
google.maps.geometry.spherical.computeArea(yourPolygon.getPath());
は正確ですが、自己交差していないポリゴンにのみ適用されます。ポリゴンが自己交差すると、事態はひどく間違っています。あなたはBradが与えたリンクhttp://geojason.info/demos/line-length-polygon-area-google-maps-v3/でそれを試すことができます。 4〜5本の交線を描き、頂点で遊んでみましょう。面積の計算が間違っているように見えます。
あなたが納得していない方は、ここでの例です:
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);
}
バグレポート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
は、このAPIは、アカウントに土地の標高がかかります?。私はGPSデバイスから座標を取得します。 –
いいえ、完全に滑らかな球状の地球を仮定しています。あなたが本当に望むようなサウンドは、デジタル標高モデルの表面積です。これはGRASS GISのr.surf.area関数で計算できますが、もっと知りたいのであればgis.stackexchange.com – Spacedman
@ Spacedman:Google Mapsと統合することはできますか? –