2016-07-20 7 views
1

以下はポリゴンを作成するコードですが、これを編集可能にしたいので、マップするには「編集可能:true」オプションを渡しました。 まだ形状は編集できません。編集可能なポリゴンを作成して編集した後、編集したlat Lngを任意のイベントで取得します

this.map = L.mapbox.map('map', null, {editable: true}).setView(DEFAULT_LAT_LONG, DEFAULT_ZOOM); 
    this.drawnItems = L.featureGroup().addTo(this.map); 
    this.drawControl = new L.Control.Draw({ 
     position: 'topright', 
     draw: { 
      polygon: { 
       shapeOptions: CONSTANTS.POLYGON_OPTION, 
       allowIntersection: false, 
       drawError: { 
        color: 'orange', 
        timeout: 1000 
       }, 
       showArea: true, 
       metric: false, 
       repeatMode: false 
      } 
     }, 
     edit: { 
      featureGroup: this.drawnItems 
     } 
    }); 
    this.drawHandler = new L.Draw.Polygon(this.map,this.drawControl.options.draw.polygon); 
    this.drawHandler.enable(); 
    this.map.on('draw:created', function(e) { 
     this.drawnItems.addLayer(e.layer); 
     this.calculateArea(e.layer); 
     this.mapState = MAP_STATE.NONE; 
    }.bind(this)); 
+0

ポリゴンを編集可能にしたくありませんか?おそらくマップコンストラクタではなく、ポリゴンコンストラクタで 'editable:true'を渡す必要があります。 – geocodezip

+0

私もそれをしましたが、うまくいきません。 – Kalashir

+2

リーフレットは編集可能な図形をサポートしていません。追加のライブラリが必要です(例:[Leaflet.Editable](https://github.com/Leaflet/Leaflet.Editable)) –

答えて

関連する問題