使用leaflet.draw,我实例化了drawControl:
scope.drawOptions = {
position: 'topright',
draw: {
polyline: false,
polygon: {
icon: new L.DivIcon({
iconSize: new L.Point(16, 16),
className: 'leaflet-div-icon leaflet-editing-icon my-own-class'
}),
allowIntersection: false,
drawError: {
color: '#5878B8',
message: '<strong>Oh snap!<strong> you can\'t draw that!'
},
shapeOptions: shapeOptions
},
circle: false, // Turns off this drawing tool
rectangle: false,
marker: false
},
edit: {
featureGroup: self.featureGroup
}
};
scope.drawControl = new L.Control.Draw(scope.drawOptions);
map.addControl(scope.drawControl);
但是进入编辑模式时,样式会恢复为“默认”。我试图通过以下方式解决这个问题:
map.on('draw:editstart', function(e) {
scope.drawControl.setDrawingOptions({
polygon: {
icon: new L.DivIcon({
iconSize: new L.Point(16, 16),
className: 'leaflet-div-icon leaflet-editing-icon my-own-class'
})
},
})
});
但这没有帮助。有什么建议么?
有一个已关闭的 github 问题,但我无法弄清楚:https ://github.com/Leaflet/Leaflet.draw/issues/48#issuecomment-141546589
如果有人想玩,我创建了这个 jfiddle:http: //jsfiddle.net/markdickersonvt/mwz7pg2n/