Kun*_*pal 19 gps google-maps polygon map google-maps-api-3
我正在寻找一种精确的算法或服务来计算地球上的表面积,其中点数是根据GPS坐标计算的.
我正在使用谷歌地图Api版本3,并根据记录的坐标绘制多边形,但我不认为计算多边形面积的标准方法将考虑斜率(山丘).我需要为这样的东西做轮廓吗?
是否有任何第三方服务可能是ArcGis或其他考虑到斜坡的服务.
Bra*_*rad 41
是的,这绝对是可能的.这里有一个带示例代码的快速教程:
相关部分是这样的:
google.maps.geometry.spherical.computeArea(yourPolygon.getPath());
Run Code Online (Sandbox Code Playgroud)
官方文件:
http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical
Kos*_*tis 10
布拉德的回答
google.maps.geometry.spherical.computeArea(yourPolygon.getPath());
Run Code Online (Sandbox Code Playgroud)
是正确的,但要注意,它只适用于不自相交的多边形.当多边形开始自相交时,事情就会发生可怕的错误.您可以使用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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
47434 次 |
| 最近记录: |