5

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);

ただし、編集モードに入ると、スタイルは「デフォルト」に戻ります。私はこれと戦おうとしました:

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/

4

1 に答える 1