我正在Google地图上绘制三个多边形,第一个多边形在第二个多边形中,第二个多边形又在第三个多边形中。
我想在JavaScript中获取它们的差集作为另一种形状。
P3-P2? P2-P1?
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;
参考:https://developers.google.com/maps/documentation/javascript/reference?csw=1#spherical
paths
(复数)帮助了我。const polygon = new google.maps.Polygon({
paths: [path1, path2, path3],
// ...
});