【问题标题】:Create editable polygon and after editing it get the edited lat Lng in any event创建可编辑的多边形,并在编辑后得到编辑后的 ​​lat Lng
【发布时间】:2016-07-20 11:21:17
【问题描述】:

下面是我创建多边形的代码,我想让它可编辑,所以我已将“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.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));

【问题讨论】:

  • 您不想使多边形可编辑吗?您可能需要在多边形构造函数而不是地图构造函数中传递editable:true
  • 我也这样做了,但它不起作用。
  • 传单不支持可编辑的形状,你需要一个额外的库(例如Leaflet.Editable
  • @HoussemFat :我添加了 editable:true ,现在我的多边形是可编辑的。如果我们编辑创建的多边形,那么我们可以在哪个地图事件中获得编辑图层?

标签: leaflet mapbox leaflet.draw


【解决方案1】:

您需要在选项中设置editable: true

参考此链接:https://developers.google.com/maps/documentation/javascript/examples/user-editable-shapes

【讨论】:

    猜你喜欢
    • 2018-02-11
    • 1970-01-01
    • 2019-03-16
    • 2020-07-23
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多