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

Flask example with interaction widgets #88

Closed
achourasia opened this issue Feb 27, 2015 · 3 comments
Closed

Flask example with interaction widgets #88

achourasia opened this issue Feb 27, 2015 · 3 comments
Labels
wontfix This problem or request is outside the scope of folium

Comments

@achourasia
Copy link

Lets create an example where we interact with the generated map with Flask as backend server. The idea is demonstrate example where you could seamlessly modify the map information via provided user interface,

Say we create a Choropleth of US state as GeoJson
a) Create a range slider to select a state from 1 to 50, the selected state will get highlighted with a different color.
b) Simulate a value associated with each state say GDP or population. Create a button named simulate which generates random populations for each state. Each time a user clicks this button a new random distribution of say population is generated and the map is updated with a color scale.

@birdage
Copy link
Contributor

birdage commented Mar 2, 2015

@achourasia i was thinking about this over the weekend. I think the above description is actually outside the scope of the folium project, if you wanting to use flask to serve data via a map interface in the above described way i would actually skip folium and go straight to a JS leaflet map/UI with a flask backend, leveraging a geo json/jsonp response. Folium is great for simple map plotting but you are talking about some serious data.

There is however twos ways you could do it in folium.

  1. Add two buttons, one to go forward in time, one to go back, these time are from an array list. These buttons call a function to create a folium map with the geojson, or update the map with a new geojson. And thus when you change time using the buttons a different geojson gets loaded.

  2. Add all the layers to the folium map, then make it possible to only select one from the map controls (similar to the wms layers), then hide the other ones.

the above two ways are a bit of a hack, and it would actually be easier to just do this in leaflet and JS...

a simple google search found something very similar...

http://dwilhelm89.github.io/LeafletSlider/ with source here

https://github.com/hallahan/LeafletPlayback

http://zevross.com/blog/2014/08/12/add-a-before-after-map-slider-to-a-leaflet-map/

http://leafletjs.com/plugins.html

@birdage birdage added the wontfix This problem or request is outside the scope of folium label Mar 2, 2015
@achourasia
Copy link
Author

Thanks for the thought and links. Yes going directly from FLASK or for that matter any server to leaflet is a good idea. The key reason for me to use Folium is have everything could be shipped as a Python app and no need to mess around with JS, etc. While Folium concept is nice, but anything dynamic requires server support and it does not have to be a heavy application. The examples I mentioned above are not that complicated, its just that instead of cooking data single time, we are cooking on demand. My thinking is that such an example could potentially provide a wider utility for Folium, but if this is out of scope, thats fine with me.

@birdage
Copy link
Contributor

birdage commented Mar 2, 2015

@achourasia i think its out side the scope for right now, unless you did one of the options above, i.e button to reload the map with different data in it, or load all the data then just select which layer to use.

Will close for now, but certainly reopen or generate new issues if you have any.

@birdage birdage closed this as completed Mar 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This problem or request is outside the scope of folium
Projects
None yet
Development

No branches or pull requests

2 participants