Skip to content
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

Geoman support as draw controls alternative? #1165

Open
maartenbreddels opened this issue Jan 9, 2024 · 7 comments
Open

Geoman support as draw controls alternative? #1165

maartenbreddels opened this issue Jan 9, 2024 · 7 comments

Comments

@maartenbreddels
Copy link
Member

Hi,

We've been looking into the draw controls for ipyleaflet. One thing we were interested in (cc @mangecoeur ) was controlling the draw controls programmatically, using our own controls (not the builtin toolbar).
It seems this is not possible with the leaflet-draw plugin (bad design?), and the project seems dead:

Most people suggest using Geoman / https://github.com/geoman-io/leaflet-geoman in the above issues, which seems like a good alternative.
I always hate breaking changes, so I suggest we add Geoman draw controls to ipyleaflet, and keep the current draw controls as they are right now.
Will a PR for this likely be merged for ipyleaflet if we do the work?
cc @iisakkirotko @mariobuikhuizen

Regards,

Maarten

@martinRenou
Copy link
Member

Hey Maarten! 😃

Thanks for opening an issue.

Sounds good to me. We can probably start by introducing a geoman control as you suggest, and add a note in the documentation to suggest using this one instead of the old leaflet-draw.

Happy to review a PR!

@maartenbreddels
Copy link
Member Author

Awesome, yes, we should mention in the docs why both are there and direct people to the new one.

@martinRenou
Copy link
Member

I always hate breaking changes, so I suggest we add Geoman draw controls to ipyleaflet, and keep the current draw controls as they are right now.

Would we be able to keep the same Python API while using geoman instead of leaflet-draw in the front-end?

It seems that having leaflet-draw there could break ipyleaflet entirely. leaflet-draw makes use of the initHook feature of LeafletJS, which allows them to patch the creation of e.g. markers. This seems to cause some issues in some cases (I have difficulties spotting the exact cases for now). So not having leaflet-draw in the page may be good.

Also I'm wondering if those plugins will not collide.

@maartenbreddels
Copy link
Member Author

So, you are asking, can we replace leaflet-draw with geoman?

@martinRenou
Copy link
Member

Yes

@iisakkirotko
Copy link
Contributor

Hey @martinRenou and @maartenbreddels! I took a look at this a while ago, so here are some of my thoughts on the discussion:

Would we be able to keep the same Python API while using geoman instead of leaflet-draw in the front-end?

The one thing where I don't think there is at least feature parity is polyline, which I don't think Geoman has. Otherwise I don't foresee any issues with this that can't be overcome.

leaflet-draw makes use of the initHook feature of LeafletJS, which allows them to patch the creation of e.g. markers. This seems to cause some issues in some cases (I have difficulties spotting the exact cases for now).

Correct me if I'm wrong, but I think that Geoman also uses the initHook, since it initializes itself automatically. There is an option to not automatically initialize, but initHook is still used on layers/maps where we want to enable Geoman. Let me know if you manage to pin down any particular issues / what kinds of issues you think might come up.

Also I'm wondering if those plugins will not collide.

In my (admittedly brief) exploration of this I didn't run into any issues. I don't know if this might be the case when both are activated.

@maartenbreddels
Copy link
Member Author

The company requesting/funding this feature asked if it was possible to advertise that they sponsor ipyleaflet. Would this be possible?
I think it's really good that people see a project like this can be sponsored, and I think it's fair to them.

Would a sponsor section in the main readme be ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants