小编Mar*_*son的帖子

如何在leaflet.draw编辑模式中设置divicons的样式?

使用leaflet.draw,我实例化drawControl I:

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);
Run Code Online (Sandbox Code Playgroud)

但进入编辑模式时,样式将恢复为"默认".我尝试用以下方法解决这个问题

map.on('draw:editstart', function(e) {
  scope.drawControl.setDrawingOptions({
    polygon: {
      icon: new L.DivIcon({
        iconSize: new L.Point(16, 16), …
Run Code Online (Sandbox Code Playgroud)

icons editmode draw leaflet

4
推荐指数
1
解决办法
1657
查看次数

标签 统计

draw ×1

editmode ×1

icons ×1

leaflet ×1