javascriptleafletesrileaflet.drawesri-leaflet

Error while trying to delete/edit shape using leaflet draw - ESRI


I am trying to delete/ edit a shape created using leaflet draw.

I get the following error when trying to edit the shape created.

I'm using leaflet 1.0-rc1 and leaflet draw version 0.3.2.

enter image description here

Here's my code:

 var map = L.map('map').setView([28.7041, 77.1025], 13);
    L.esri.basemapLayer("Topographic").addTo(map);
    //Edit Toolbar

    var drawnItems = new L.FeatureGroup();
    map.addLayer(drawnItems);

    var drawControl = new L.Control.Draw({
        draw: {
            position: 'topleft',
            polygon: {
               allowIntersection: false,
                drawError: {
                    color: '#b00b00',
                    timeout: 1000
                },
                showArea: true
            },
            circle: {
                shapeOptions: {
                    color: '#662d91'
                }
            },
            polyline: false,
            rectangle: true,
            marker: false,
        },
        edit: {
            featureGroup: drawnItems
        }
    });
    map.addControl(drawControl);

    map.on('draw:created', function (e) {
        var type = e.layerType,
        layer = e.layer;
        drawnItems.addLayer(layer);
    });

Solution

  • For Leaflet 1.0, you have to use Leaflet.draw leaflet-master branch, as mentioned on the repo home page:

    Support for Leaflet 1.0 is in development at the leaflet-master branch.

    Demo: https://plnkr.co/edit/PmHj1FhOoeZBEsAnEu1z?p=preview

    That means that you may not have all the latest features from the plugin unfortunately (e.g. Display Polyline length in feet using Leaflet.Draw toolbar)