-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draw control can't stop drawing after draw more than one shape #1119
Comments
+1 also might be somewhat related: I can't draw more than one polygon, the second polygon I try to draw never closes. Similar to. |
I am using:
|
I see something similar, the draw menu stays open and you have to click save then cancel and it seems to work but its janky. Checking the javascript console I see the error:
My unconfirmed hunch digging into the code is that line 39 in DrawControl.js this.feature_group = L.geoJson([], {
style: function (feature) {
return feature.properties.style;
}, is setting a property as a function which fails to be synced by the widget. |
also possibly related jupyter-widgets/ipywidgets#3735 |
I can reproduce your findings by running ipyleaflet in Jupyer-Lab, editing a polygon and hitting save. This does nothing and the console (with breakpoints) shows the following errors:
Which is caught and logged:
resulting in the This can be traced to the ipywidget serialization logic here: which is corroborated by the above discussion about moving away from Can we clean up |
…tream serialization. - Fix for jupyter-widgets#1119 - The main issue is that a `style()` function is added to the GeoJSON object in `create_obj()`, which triggers an error at serialization time: https://github.com/jupyter-widgets/ipywidgets/blob/e1718c2b3bf0b143580ef87f71c55fbc6ed50a77/packages/base/src/widget.ts#L587 - This is because `structuredClone` throws an error for functions: https://web.dev/structured-clone/#features-and-limitations. While the article mentions drawbacks for using `JSON.parse(JSON.stringify(...))`, I believe that this component does not produce any non-primitive properties, so will remove any offending lines. - Tested by placing a breakpoint and testing directly on the browser.
@J-Bindel |
No, sorry 😔 |
The JS library behind the draw control is not maintained so there is a new PR to use geoman instead, which should hopefully also fix this issue On 3 Apr 2024, at 21:04, Jeremy Bindel ***@***.***> wrote:
No, sorry 😔
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Hey,
I am using ipyleaflet for my work. I would like to draw rectangles on my map with DrawControl.
The first drawing works but when I click again on the rectangle for example, DrawControl won't stop drawing rectangles until I clear them all.
The above code reproduces the bug.
Here is what I get.
Screencast from 19-06-2023 18:39:08.webm
The text was updated successfully, but these errors were encountered: