You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
@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.
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.
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...
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.
Activity
birdage commentedon 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.
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.
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
achourasia commentedon Mar 2, 2015
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 commentedon 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.