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.

Can't enable editing on a polyline

See original GitHub issue

On the current master branch I can’t manually enable editing mode on a polyline.

Calling layer.editing.enable() results in an error:

 Uncaught TypeError: Cannot set property 'fill' of undefined

And I believe that leads us back to this line: https://github.com/Leaflet/Leaflet.draw/commit/07b1448f4eba33982f662398988f0337ee55cc02#diff-417e4ee28e399d7a4c5dbc14f6897ffaR1153


I can go into editing mode using the control on the map, but not when I try to enable the editing mode myself.

I have created a small project to help demonstrate this issue.

The line that causes the error is: https://github.com/kyletolle/leaflet-draw-polyline-enable-editing-bug/blob/master/index.html#L133

If you pull down the project, open it in your browser, and then click on the polyline, you can see the error in the dev tools console. Try clicking on the marker, and then dragging it around. You can drag it with no problems. You can click on the polygon to get it into editing mode too. So going into editing mode works on some features, but not the polyline.

Hope this helps narrow down where the issue might be.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
kyletollecommented, Feb 13, 2015

A workaround for this is to set the layer’s editing option to an empty object before enabling editing.

This doesn’t give any of the default styling when editing, but it does keep things from crashing.

layer.options.editing || (layer.options.editing = {});
layer.editing.enable()
9reactions
ddproxycommented, May 12, 2016

When you add a polyline to the map, add it to the drawnItems feature Layer (or whatever featureGroup you are using for the items you want to edit).

http://jsfiddle.net/ddproxy/suL12z93/3/


var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
...
var drawControl = new L.Control.Draw({
    edit: {
        featureGroup: drawnItems
    }
});
...
drawnItems.addLayer(L.polyline(myLatLngs));
Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot edit polyline - Autodesk Community - AutoCAD
I've never seen this before: I have a block that I got from a German machine manufacturer that I need to draw a...
Read more >
Cannot Edit Vertices of Polyline Feature - GIS Stack Exchange
1 Answer 1 · Check to make sure that the line does not have a duplicate geometry. · Run ArcToolbox>Data Management Tools>Features>Repair Geometry....
Read more >
Polyline Edit - forum.datacad.com View topic
When Adding, Moving, or Dragging vertexes; can I enable Orthomode to be on? Even if Orthomode is on, DC still wont edit polylines...
Read more >
Enable and disable editing—ArcGIS Pro | Documentation
In this topic ... On the Edit tab, in the Manage Edits group, the Edit button enables and disables editing tools and feature...
Read more >
Tips to Edit Polylines Faster in AutoCAD! Quick Edit ... - YouTube
Your browser can't play this video. Learn more. Switch camera ... Tips to Edit Polylines Faster in AutoCAD! Quick Edit Lines, Polygons etc....
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