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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 22:10:15  来源:igfitidea点击:

onChange event for Google Maps APIv3 drawing manager

javascriptjavascript-eventsgoogle-maps-api-3shapes

提问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 completeevents to trigger actions when a shape is added to the map (eg. overlaycompleteor polygoncomplete)-- but I am also allowing the user to edit the completed shapes.

complete当形状添加到地图(例如overlaycompletepolygoncomplete)时,我可以使用事件来触发操作——但我也允许用户编辑完成的形状。

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:

可在此处找到编辑事件列表:

Editable events

可编辑的事件

Dragging events

拖动事件

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');
  });
});

http://jsfiddle.net/Vvk4d/

http://jsfiddle.net/Vvk4d/

You can use the same approach for polygons/rectangles.

您可以对多边形/矩形使用相同的方法。