Subtract two polygons on google map

I draw three polygons on a Google map that the first is in the second and the second in the third. I want to subtract them in javascript as another form.

P3-P2? P2-P1?

+3
source share
1 answer

Lighter than I thought:

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

0
source

Source: https://habr.com/ru/post/1794527/


All Articles