Google Maps API v3中的remove_at事件何时触发? [英] When is remove_at event in Google Maps API v3 triggered?

查看:99
本文介绍了Google Maps API v3中的remove_at事件何时触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用google map api v3,并希望添加编辑折线的功能。从google文档开始。折线处于编辑模式时会触发3个事件。

I am working on google map api v3 and want to add a feature of editing the polyline. As of the google documentation. There are 3 events fired when a polyline is in edit mode.


  1. insert_at

  2. set_at

  3. remove_at

我知道何时触发前两个事件,并且也能够获取已编辑的坐标。我也想删除一个节点,但不确定如何工作?谁能告诉我何时将触发事件 remove_at?

I know when first two events are fired and am able to get the edited coordinates as well. I also want to delete a node but not sure how it works?. Can anyone tell me when will the event "remove_at" will be fired ?

推荐答案

'remove_at'会在您撤消编辑到现有的覆盖层上,导致控制点被删除。

'remove_at' will be triggered when you undo an edit to an existing overlay that results in control point(s) getting removed.

我创建了小提琴来演示

从小提琴中:

var myLatlng = new google.maps.LatLng(60.629765, 6.424094);
var myOptions = {
    zoom: 14,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var drawMan = new google.maps.drawing.DrawingManager({
    map: map,
    drawingControl: false,
    polygonOptions: {
        editable: true,
        draggable: true
    }
});

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

google.maps.event.addListener(drawMan, 'overlaycomplete', function (event) {
    // When draw mode is set to null you can edit the polygon you just drawed
    drawMan.setDrawingMode(null);

    google.maps.event.addListener(event.overlay.getPath(), 'remove_at', function () {
        alert('remove_at triggered');
    });
});

这篇关于Google Maps API v3中的remove_at事件何时触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆