Initiate polygon drawing from custom button

谁说胖子不能爱 提交于 2019-12-01 14:16:38

问题


I love the new polygon drawing options and have been playing with them for a couple of days.

On the official documentation I see that it is possible to initiate the drawing of a polygon by clicking on a button external to the map. Does anybody know how to do this? http://code.google.com/apis/maps/documentation/javascript/overlays.html#updating_the_drawing_tools_control

In other words I would like to be able to create a button similar to the "Delete selected shape", but which will instead start the drawing of the polygon: http://googlegeodevelopers.blogspot.com/2011/11/make-your-map-interactive-with-shape.html


回答1:


Use setDrawingMode() function of the google.maps.drawing.DrawingManager object.

In the button click event handler, call:

drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON);

To quit the drawing mode, call:

drawingManager.setDrawingMode(null);


来源:https://stackoverflow.com/questions/8187758/initiate-polygon-drawing-from-custom-button

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