javascript Google Maps APIv3 绘图管理器的 onChange 事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14632134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
onChange event for Google Maps APIv3 drawing manager
提问by user101289
I'm using the GMaps API v 3 Drawing Managerto let users draw shapes on a map.
我正在使用 GMaps API v 3绘图管理器让用户在地图上绘制形状。
I can use the complete
events to trigger actions when a shape is added to the map (eg. overlaycomplete
or polygoncomplete
)-- but I am also allowing the user to edit the completed shapes.
complete
当形状添加到地图(例如overlaycomplete
或polygoncomplete
)时,我可以使用事件来触发操作——但我也允许用户编辑完成的形状。
Is there a way to trigger an action when a shape is changed? I can't see any way to fire another function when a shape is modified.
有没有办法在形状改变时触发动作?当修改形状时,我看不到任何方式来触发另一个函数。
Thanks
谢谢
回答by dmk
List of editing events can be found here:
可在此处找到编辑事件列表:
Here is an example how to use it with DrawingManager when a circle's radius has changed:
这是一个示例,当圆的半径发生变化时,如何将其与 DrawingManager 一起使用:
google.maps.event.addListener(drawingManager, 'circlecomplete', function (circle) {
google.maps.event.addListener(circle, 'radius_changed', function () {
console.log('radius changed');
});
});
You can use the same approach for polygons/rectangles.
您可以对多边形/矩形使用相同的方法。