Leaflet顶点点击事件

Leaflet vertex click event

如何 fire/listen 来自 L.Polygon 顶点的点击事件?

用户使用以下方法制作多边形:

fobDrawPolygon: function(iobMap) {
        var obPolygon = new L.Draw.Polygon(iobMap, {
            allowIntersection: false,
            showArea: true,
            shapeOptions: {
                color: '#000'
            }
            //repeatMode: true
        });
        obPolygon.options.touchIcon.options.iconSize = [12, 12];
        obPolygon.enable();
        return obPolygon;
    },

创建多边形后,可以编辑其顶点:

onDrawFeature: function(iobMap, iobFeatureGroup) {
        var me = this;              
        iobMap.on(L.Draw.Event.CREATED, function(event) {
            var obLayer = event.layer;
            obLayer.options.editing = {};
            obLayer.editing.enable();
            iobFeatureGroup.addLayer(obLayer);
        });
    }

所以,多边形已经画好了,我想听听他们顶点的咔嗒声

Leaflet 1.3.1

Plugin Leaflet.Draw

Notice I don't use control toolbars

在寻找它之后,我发现了一个轻量级库来控制传单中几何图形的编辑:

首先,将 editable 属性 添加到地图

var map = L.map('map', {
 editable: true,
 editOptions: {…} //not required
});

然后,启用功能版

onDrawFeature: function(iobMap, iobFeatureGroup) {
    var me = this;
    iobMap.on(L.Draw.Event.CREATED, function(event) {
        var obLayer = event.layer;
        iobLayer.enableEdit(iobMap); //enable edition            
        me.cacheLayer = iobLayer;
        iobFeatureGroup.addLayer(obLayer);
    });
}

最后听到多边形的顶点点击

me.cacheLayer.on({
    "editable:vertex:click": function(e){console.log("You touch me", e)}
});

在此处查找图书馆:

If someone has another way of doing it, please share it, thank you!