-
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
Dynamicaly change/update markers #848
Comments
Sounds like an interesting project! In short: unfortunately folium cannot do this, though it could be an interesting addition. It's import to understand that folium generates the html with Leaflet javascript and after that is finished. So anything that happens on the map after generation is outside of folium's scope. Now there have been ideas of getting callbacks from javascript back to python, mainly for in the Jupyter environment. I can imagine something like that could also work for Flask or Django, where some javascript ajax calls retrieve new data. This is not available in folium though, but of course you're welcome to work on adding this. folium works great for creating ad hoc maps with python data. For your application I would suggest not to use folium but to use Leaflet directly. You need a fixed map layout and very good integration with your web application, not to create various maps with differing Python data, which is folium's strong point. Of course you can use a map created by folium as inspiration for how to use Leaflet of course. But that's my opinion. Hope it helps! Maybe others will chime in as well. |
Thanks for your answer. I see that, using JS directly it is the only option. I have few ideas in my head , you say that is possible to add data immediately via ajax? Maybe I will try to keep data about layer of markers in DB and check the version of layer every 30 sec( for example) and update it then. I will search some information about that idea in JS and if I figure out something I will share the solution. Thank you :) |
A quick search shows that there is a lot written about for example dynamic data for Leaflet. Good luck with this! I'll close the issue if that's alright with you, feel free to reopen if you have something that could be done about folium. Also, it would be great if you could add any solutions you come up with here and help others who are coming from folium and want to do a similar thing. |
I`m want to make webapp with Django which displays a map for every user on the main page. What I want to have:
1.Every user can add a marker to map and every other user see those markers immediately.
2.Every user can delete marker if he is owner of that marker and other user will see those changes immediately.
3.If user A "is intrested" with user B (this information is stored in DB) he (A) sees markers of user B in a different way than others ( different color or marker image).
My idea is to create once a html file without markers and creat separate function which will be updateing map for every user separetly. I want to use Memecahce to dynamic update the map. If somebody add new marker, specific function shoudl add new marker without makeing and reolading whole map. I need that becouse application can have a lot of user with a lot of markers so it could be too expensive for server(reolading all markers after every update).
My question : How to change/add markers to map dynamicaly after creating a map file or maybe you have better idea to solve that problem.
The text was updated successfully, but these errors were encountered: