leafmap icon indicating copy to clipboard operation
leafmap copied to clipboard

Added typehints to the foliumap.Map init

Open JJFlorian opened this issue 1 year ago • 4 comments

As discussed in my previous PR: here a PR with just the Init updates on foliumap.Map. This enhances the docs popup in IDEs:

image

JJFlorian avatar Jul 04 '24 14:07 JJFlorian

Initially, I removed the **kwargs completely, but now I realize that shouldn't be the case.

Firstly, this change causes the docs builder to crash since ipyleaflet parameters are added to a foliumap in some places. Secondly, it removes the ability to use folium.Map parameters that are not part of the foliumap.Map class.

For now i have reintroduced the **kwargs and placed them bank in the super.init

I might be missing something, so please review this PR critically 😄

JJFlorian avatar Jul 04 '24 15:07 JJFlorian

Some parameter names are different between folium and ipylealet, such as location vs center, and zoom_start vs zoom. The kwargs allows those parameters to be interchangerable.

giswqs avatar Jul 04 '24 15:07 giswqs

Yes, I figured. That why I have this mapping: super().init( location=center, zoom_start=zoom, min_zoom=min_zoom, max_zoom=max_zoom, control_scale=scale_control, height=height, width=width, **kwargs, )

This seems to works, but the problem might be that the current selection of parameters might imply that those are the only options, while it is still possible to pass folium Map parameters (for example crs, no_touch etc.).

Maybe the best option here is to add them all to the foliumap.Map, to make sure the IDE shows all available parameters. By still leaving the **kwargs in, it should work completely interchangerable with ipyleaflet, while having a 100% covered IDE doc popup for all parameters that actually work for Folium.

I could extend this PR later this week.

JJFlorian avatar Jul 04 '24 15:07 JJFlorian

I did some prunning to reduce the repo size from 1.6 GB to 250 MB. The seems to have caused issues for your PR. Sorry about that. You might want to clone the repo again and create a new branch. Then just overwrite the few files you have modified. This is can avoid the merge conflict issue.

giswqs avatar Jul 12 '24 16:07 giswqs

Your pull request are in conflict @JJFlorian, please fix it!

mergify[bot] avatar Dec 14 '24 20:12 mergify[bot]

@JJFlorian Sorry to close the PR for now. Otherwise, you will keep receiving the merge conflict notifications from pre-commit. If you want to continue the work, please clone the repo again and overwrite the folium.py. Sorry for the inconvience.

giswqs avatar Dec 14 '24 21:12 giswqs