-
Notifications
You must be signed in to change notification settings - Fork 364
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
feat: introduce leaflet-geoman as an alternative to leaflet-draw #1181
Conversation
@giswqs do you use DrawControls a lot? I wonder if you are willing to test this PR. We have to break things. |
Yes, I can give it a try. Do I Just pip install from the branch? Anything else I need to do to make sure the JS part is included? |
I think that should work fine. |
It seems the position of the draw control is not working properly. In the example below, the DrawControl is supposed to be placed beneath the LayersControl, but instead it is being added above the ZoomControl. Same thing happens when adding the draw control to other position, e.g., from ipyleaflet import Map, LayersControl, FullScreenControl, DrawControl, GeomanDrawControl
m = Map(center=[40, -100], zoom=4)
m.layout.height='600px'
m.scroll_wheel_zoom=True
m.add(FullScreenControl())
m.add(LayersControl(position='topleft'))
draw_control = DrawControl(position='topleft')
m.add(draw_control)
m |
Can't enter text when the text layer is initially created. Need to click on the edit layer button in order to add text. The JavaScript version can add enter text when the layer is added. No need to click on the edit layer button. https://www.geoman.io/docs/text-layer from ipyleaflet import Map, GeomanDrawControl
m = Map(center=(50, 354), zoom=5)
draw_control = GeomanDrawControl()
draw_control.text = {
"textOptions": {
"text": "Geoman is fantastic! 🚀"
}
}
m.add(draw_control)
m.layout.height = '600px'
m.scroll_wheel_zoom = True
m |
How to add the marker tool to the draw control? The following code does not work. from ipyleaflet import Map, GeomanDrawControl
m = Map(center=(50, 354), zoom=5)
draw_control = GeomanDrawControl()
draw_control.marker = {
"markerStyle": {
"draggable": True
}}
draw_control.polyline = {
"pathOptions": {
"color": "#6bc2e5",
"weight": 8,
"opacity": 1.0
}
}
m.add(draw_control)
m.layout.height = '600px'
m.scroll_wheel_zoom = True
m |
Thanks a lot for your feedback @giswqs! I'll take a look at the issues later this week. |
Hey @giswqs! b8863cc should address all of your comments, with the exception of the issue with the differing capitalisation of "polygon". The |
Hi all, first of all, some credits, and thank you's: Iisakki: Thank you for the hard work you put into building this feature. A lot of energy went into it. @giswqs Thank you for the thorough review, it has improved the quality and backwards compatibility a lot. I talked to @martinRenou privately and expressed my concerns about breaking backward compatibility despite my best efforts to avoid that.
In the future, when needed, if we do a major release, we can then:
I hope everyone agrees that's a safe and frictionless path forward. cheers, Maarten |
Thanks a lot for that work! ipyleaflet is really missing contributors right now. I personally don't have time/energy to continue any maintenance on it, but I'm happy to make releases from time to time. Is the PR ready? Happy to give it a final review/merge. |
Hi @martinRenou! I'll make this PR reflect the approach @maartenbreddels outlined in #1181 (comment) today, and open a draft PR for the future breaking change. So I expect this to be fully ready for review later today! |
543aea1
to
a053f7e
Compare
@martinRenou PR should be ready for final review! The installation errors seem to be due to an upgrade to |
Thanks! I just rebased from the UI, you'll need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small issues.
Btw, I love how the compatibility part is only on the Python side.
Co-authored-by: Maarten Breddels <maartenbreddels@gmail.com>
previously `circlemarker` incorrectly defaulted to using `markerStyle`, while it isn't a leaflet marker layer. Moreover, polyline and polygon would use the old (`shapeOptions`) by default even with geoman, where it should be `pathOptions`. This was fixed by the compatibility layer, but this way the defaults are clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinRenou do you think we can merge this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This replaces the old leaflet-draw implementation with a leaflet-geoman based one, in accordance with #1165. The change should be backwards compatible in that even though leaflet-draw is no longer used on the front end, the functionality is available identically from the python side.