-
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
add Draw plugin #720
add Draw plugin #720
Conversation
@@ -11,6 +11,7 @@ | |||
from __future__ import (absolute_import, division, print_function) | |||
|
|||
from folium.plugins.boat_marker import BoatMarker | |||
from folium.plugins.draw import Draw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'folium.plugins.draw.Draw' imported but unused
Hi @ocefpaf , |
Yeah, that is the goal. I want to avoid telling people to just use We could at least try to create a hook to save a GeoJSON file though... That would be helpful too. |
BTW I used this in the past with success: http://jakevdp.github.io/blog/2013/06/01/ipython-notebook-javascript-python-communication/ |
Yes, this has to be updated but may work. A difficulty lies in the fact that our figure is embedded into an Iframe; meaning that you don't have the same javascript environment as the main notebook. We did this to prevent folium and the notebook's javascript to break eachother... Another workaround could be to go through the API and use something like:
but you need to configure the auth cookie properly |
Totally forgot about that!
We should take a look at how ipyleaflet is doing that. Maybe there is not much interference as we expect.
Seems too hacky, no? |
@BibMartin I'll merge this as-is now and we can revisit the Python variable integration later. There are people waiting on this functionality. |
👍 Shall we open a new issue for this or let #702 hold the question ? |
#702 is fine. Thanks! |
I don't know if this is possible, but I was thinking of using this on a flask website. The plugin works fantastic, but is it possible to load to a database instead of a jupyter notebook? I think that would be an easier commit than a standard jupyter notebook? I did a google search for pulling this data and found this bookmark which allows a download of the coordinates? |
Not sure what you mean. I am terrible with databases.
That looks awesome! I'll take a look if I can add that functionality. Better than the current copy-n-paste and while |
RE: Database I guess what I am trying to figure out is illustrated here: when a person clicks on the layer jquery will then run a python command to update a database. I will try looking into this. Thank you for such a wonderful plugin! |
PR #727 added the export button option. Not exactly what you want but that is a start in you want to create your own plugin based on that. |
add Draw plugin
@BibMartin I know you are quite busy but I'd appreciate if you take a look at this.
Specially if you think of a way to get the GeoJSON back as a python variable.
Right now if you click on the object you'll get an JS alert with the GeoJSON.
I tried:
To return a
coords
variable, but that seems to no longer work. It seems that they deprecated it and now the only way to do this is via widgets. Not sure...See http://nbviewer.jupyter.org/github/ocefpaf/folium/blob/Draw/examples/Draw.ipynb