emilhe / dash-leaflet

MIT License
204 stars 33 forks source link

EditControl does not work with existing geometries other than dl.Marker #217

Open BartHelder opened 7 months ago

BartHelder commented 7 months ago

Hi,

In the example for EditControl, it is shown that an existing geometry can be added to the feature group at the moment of the component definition; the example uses a dl.Marker component.

 dl.FeatureGroup([
            dl.EditControl(id="edit_control"), 
            dl.Marker(position=[56, 10])]),
    ], 
...

This component is then fully editable by the EditControls. However, this does not seem to work well for any other geometry. Changing the example to use a polygon instead:

 dl.FeatureGroup([
            dl.EditControl(id="edit_control"), 
            dl.Polygon(positions=[[10,15], [15,10], [20,20]]),
    ], 
...

gives an interesting phenomenon: if the browser tab was open upon refreshing the Dash app, the polygon is loaded and is editable and interactive. However, upon refreshing the tab, the polygon fails to respond to the edit bar and the browser gives errors like these: image

Any idea what's going on here?