自定义marker点可以通过这种方式添加。
绘图后,右键菜单怎么添加?
var marker_option = { draggable:true, contextmenu: true, contextmenuWidth: 140, contextmenuItems: [{ text: '右键菜单01', callback: showMnuItem01 }] } var marker_01 = new L.Marker(e.latlng, marker_option);
// 监听标注绘制 map.on(L.Draw.Event.CREATED, function (e) { var type = e.layerType, layer = e.layer; console.log(layer); if (type === 'marker') { var marker_option = { draggable:true, // 拖拽 //repeatMode: !1, // zIndexOffset: 2e3, contextmenu: true, // 右键菜单 contextmenuWidth: 140, contextmenuItems: [{ text: '修改标注', callback: modify_Title },{ text: '删除', callback: deleteMarker }] } var marker = new L.Marker(layer._latlng, marker_option); marker.bindPopup("<b>Hello world!</b><br />I am a popup."); // map.addLayer(marker); editableLayers.addLayer(marker); return; } // 绘制标注 editableLayers.addLayer(layer); });
通过这种方式可以了