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

时间:2011-02-24 18:35:14

标签: javascript google-maps polygon subtraction

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

P3-P2? P2-P1?

1 个答案:

答案 0 :(得分:1)

我想的更容易:

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