Skip to content

Clean-up Map #1127

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

Merged
merged 4 commits into from
Apr 7, 2019
Merged

Clean-up Map #1127

merged 4 commits into from
Apr 7, 2019

Conversation

Conengmo
Copy link
Member

@Conengmo Conengmo commented Apr 7, 2019

This PR contains changes to simplify the Map class.

I removed the add_tile_layer() method, it seems like a relic from when folium didn't work with classes yet. The TileLayer should be used directly instead.

Map currently contains a lot of arguments, some of which are duplicate with TileLayer. I removed some of the more advanced ones, such as API_key, max_native_zoom, detect_retina, subdomains and nowrap. Note that these are all still available in the TileLayer class, so if someone needs them they can use the TileLayer class directly.

m = folium.Map(tiles=None)  # I want to do complicated tiles stuff
folium.TileLayer(**super_complex_options).add_to(m)

I also made the options parsing a bit simpler. Use the parse_options method to create a dictionary suitable for unpacking in the template. Don't define arrays in the template. Less code, less trouble.

Conengmo added 2 commits April 7, 2019 21:12
`map` conflicts with a Python built-in function. Convention is to use `m` instead.
Remove the `Map.add_tile_layer()` method, instead the `TileLayer` class should be used directly.

Remove a couple advanced `TileLayer` arguments from `Map`. If someone needs those they should use `TileLayer` directly.
@ocefpaf
Copy link
Member

ocefpaf commented Apr 7, 2019

I'm happy with the changes here but we will need to re-work the tests to get that to pass.

@Conengmo
Copy link
Member Author

Conengmo commented Apr 7, 2019

I'm happy with the changes here but we will need to re-work the tests to get that to pass.

Good to hear! I'm working on getting the tests working, but my environment got F-ed up so I need to fix that first :p

@Conengmo
Copy link
Member Author

Conengmo commented Apr 7, 2019

I removed the test_map_build test that uses the fol_template.html file. That test has caused me more trouble than that it has been helpful. Copy-pasting the template from a class to a test is not a useful way of writing tests.

@ocefpaf ocefpaf merged commit 99449e2 into python-visualization:master Apr 7, 2019
@ocefpaf
Copy link
Member

ocefpaf commented Apr 7, 2019

I removed the test_map_build test that uses the fol_template.html file. That test has caused me more trouble than that it has been helpful. Copy-pasting the template from a class to a test is not a useful way of writing tests.

I agree. That outlived its usefulness a long time ago. Thanks!

@Conengmo Conengmo deleted the simplify-map branch April 8, 2019 05:52
@Conengmo
Copy link
Member Author

Conengmo commented Apr 8, 2019

Thanks for the review and the merge Filipe, I appreciate it.

Reading back my last comment I must say I was a bit frustrated after an hour of trying to fix DLL problems with Anaconda on Windows :p I don’t want to be disrespectful of previous work. Instead it’s really cool to see what the work of multiple different people over multiple years has led to.

@ocefpaf
Copy link
Member

ocefpaf commented Apr 8, 2019

Reading back my last comment I must say I was a bit frustrated after an hour of trying to fix DLL problems with Anaconda on Windows :p I don’t want to be disrespectful of previous work. Instead it’s really cool to see what the work of multiple different people over multiple years has led to.

Sorry about that. The only reason to use conda via minconda to install packages (not Anaconda b/c that is the full distribution and kind of heavy-weight for us) is to install geopandas (b/c of its dependency on gdal).

The situation on Windows got better now that you can use strict channel. That will be default in the next conda release (4.7) BTW. These docs does not mention Windows exactly but it is probably the same problem. TL;DR feel free to bug me with question before wasting your time with this. I have some experience with conda package, specially those from conda-forge.

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

Successfully merging this pull request may close these issues.

3 participants