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

瘦欲@ 提交于 2020-01-25 00:58:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!