Can I force Google Maps to draw polygons with overlapping paths as a union rather than intersection?

StackOverflow https://stackoverflow.com/questions/17769380

  •  03-06-2022
  •  | 
  •  

سؤال

I'm working on a custom Google Map where I need to have place marks made up of several polygons. When I was using a KML file, the polygons would union together, however I had to abandon KML due to the need to present the infowindow programmatically from other items on the page.

Now that I'm drawing polygons directly (new google.maps.Polygon) I find that sometimes the items are joined via union and somethings via intersect. This appears to be related to how much overlap there is.

My polygons are building shapes with their corresponding labels so I've wanted to keep the two as separate paths if possible (though this isn't necessary).

Is it possible I'm missing a setting that tells the engine how to join the paths? PolygonOptions shows nothing, but perhaps there's a hidden feature to do this.

هل كانت مفيدة؟

المحلول

If you have multiple paths in a polygon, the regions will subtract if the winding direction is opposite (the relative order of coordinates i.e clockwise or counter-clockwise).

Some examples:

similar question

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top