编程语言
首页 > 编程语言> > javascript – 在谷歌地图中减去两个多边形

javascript – 在谷歌地图中减去两个多边形

作者:互联网

我在Google地图上绘制了三个多边形,第一个在第二个,第二个在第三个.
我想在javascript中将它们减去另一种形状.

P3-P2?
P2-P1?

解决方法:

我想的更容易:

var poly1Area = google.maps.geometry.spherical.computeArea(poly1.getPath());
var poly2Area = google.maps.geometry.spherical.computeArea(poly2.getPath());
var poly3Area = google.maps.geometry.spherical.computeArea(poly3.getPath());

poly2Area = poly2Area - poly1Area;
poly3Area = poly3Area - poly2Area;

ref:https://developers.google.com/maps/documentation/javascript/reference?csw=1#spherical

标签:javascript,polygon,google-maps,subtract
来源: https://codeday.me/bug/20190710/1420492.html