-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Comments
@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.
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/ |
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. |
@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. |
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.
The text was updated successfully, but these errors were encountered: