问题
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.
回答1:
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:
- http://www.geocodezip.com/v3_polygon_example_donut.html
- http://www.geocodezip.com/v3_polygon_example_donutA.html
- http://www.geocodezip.com/v3_polygon_example_donutB.html
- http://www.geocodezip.com/v3_polygon_example_donutC.html
similar question
来源:https://stackoverflow.com/questions/17769380/can-i-force-google-maps-to-draw-polygons-with-overlapping-paths-as-a-union-rathe