question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lealfet 1.0.0 Support - Editing/deleting doesn't work

See original GitHub issue

Should I still use the Leaflet-master branch for 1.0.0? Because I’m experiencing some problems with it. the Leaflet-master branch seems to be stale as the last update was made 6 months ago… (!) It’s kinda confusing.

I’m using Leaflet 1.0.0-rc1. I can succesfully draw features and they are added to the map, however, once they are added, I cannot edit/delete them as modify/delete buttons are grayed out. No errors are given.

Here’s my code:

    // Initialise the FeatureGroup to store editable layers
    let drawnItems = new L.FeatureGroup();
    this._map.addLayer(drawnItems);

    // Initialise the draw control and pass it the FeatureGroup of editable layers
    let drawControl = new L.Control.Draw({
        draw: {
          polyline: {
              metric: true
          },
          polygon: {
              allowIntersection: false,
              showArea: true,
              drawError: {
                color: '#b00b00',
                timeout: 1000
              },
              shapeOptions: {
                color: '#bada55'
              }
          },
          marker: false
        },
        edit: {
          featureGroup: drawnItems
        }
    });
    this._map.addControl(drawControl);

    // Listen for editor events
    this._map.on('draw:created', (e) => {
      let type = e.layerType,
          layer = e.layer;

        this._map.addLayer(layer);
    });

I also cannot remove the last point of the polyline.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ddproxycommented, Jun 20, 2016

I apologize for the confusion, Leaflet.Draw has not been updated for 1.0 support yet, however it is planned.

1reaction
chugcupcommented, Sep 9, 2016

@gholol I think your problem is that you have to add editable items to the drawnItems layer. That can be fixed in your ‘draw:created’ handler.

// Listen for editor events
this._map.on('draw:created', (e) => {
  let type = e.layerType,
      layer = e.layer;

    drawnItems.addLayer(layer);
});

I ran into the same problem when I started.

That doesn’t mean editing works in 1.0.0 though… you will still run into issues once the buttons become clickable 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet Marker not found production env - Stack Overflow
This is a known bug in Leaflet, the root issue is that Leaflet's icon image location is been wrongly referenced during bundling.
Read more >
Documentation - a JavaScript library for interactive maps
L.SVG or L.Canvas by default depending on browser support. ... Creates a new map pane with the given name if it doesn't exist...
Read more >
leaflet.extras.pdf
Used for adding shapes(markers, lines, polygons) and then editing them using the draw plugin. You can either set layerId or group or none...
Read more >
Read Leaflet Tips and Tricks | Leanpub
These contributors also deserve honours for the work on leaflet.js. ... circles and markers to a map and then edit or delete those...
Read more >
Create, Edit, Delete Geometrics | Leaflet-Draw Plugin | GeoDev
Tutorial Code: https://github.com/iamtekson/ Leaflet -Basic/tree/master/drawLeaflet ... Leaflet Draw Polygon | Create, Edit, Delete Geometrics ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found