4

我在谷歌地图上画了三个多边形,第一个在第二个,第二个在第三个。我想在 javascript 中将它们的减法作为另一种形状。

P3-P2 ? P2-P1 ?

4

1 回答 1

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

于 2017-09-25T20:13:27.657 回答