1

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

1 回答 1

-1

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

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

于 2017-04-14T14:51:44.073 回答