Leaflet 创建可编辑多边形,并在编辑后在任何情况下获得编辑的lat Lng
下面是我创建多边形的代码,我想使其可编辑,所以,我已将“editable:true”选项传递给贴图。 但“静止”形状不可编辑Leaflet 创建可编辑多边形,并在编辑后在任何情况下获得编辑的lat Lng,leaflet,mapbox,leaflet.draw,Leaflet,Mapbox,Leaflet.draw,下面是我创建多边形的代码,我想使其可编辑,所以,我已将“editable:true”选项传递给贴图。 但“静止”形状不可编辑 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.Contro
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));
您需要在选项中设置
可编辑:true
请参阅此链接:是否要使多边形可编辑?您可能需要在多边形构造函数而不是地图构造函数中传递
editable:true
。我也这样做了,但它不起作用。传单不支持可编辑形状,您需要一个附加库(例如)。检查此@HoussemFat:I已添加editable:true,现在我的多边形可编辑。若我们编辑创建的多边形,那个么在哪个贴图事件中我们可以得到编辑的图层?