Get layer data from polygons in Draw plugin
See original GitHub issuefrom folium import Map
from folium.plugins import Draw
m = Map()
draw = Draw()
draw.add_to(m)
m
Problem description
Hi, I’m using Folium with the Draw plugin to draw and export geojson data in Jupyter. I’m aware of the “Export” option in the Draw plugin, however I’d prefer to export the draw polygons programmatically. Is there a way I can directly access drawn objects?
When I run the above code in Juypter and draw a polygon onto the map I would expect the map object to update or for there to be some event I can listen to in order to my own state of what polygons are on the map.
Output of folium.__version__
‘0.11.0’
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Get all polygon or layer details after polygon draw in leaflet draw
I am trying to get the layer details of the map which are already overlay on the map. When leaflet draw is created...
Read more >Leaflet Draw Documentation
This tells the plugin which FeatureGroup contains the layers that should be editable. The featureGroup can contain 0 or more features with geometry...
Read more >Exporting GeoJSON with defined properties using Folium ...
on("draw:created", function(e){ // get layer and feature var layer = e. layer; feature = layer. feature = layer.
Read more >Drawing Layer (Library) | Maps JavaScript API
The DrawingManager class provides a graphical interface for users to draw polygons, rectangles, polylines, circles, and markers on the map.
Read more >Create, Edit, Delete Geometrics | Leaflet-Draw Plugin | GeoDev
Leaflet Draw Polygon | Create, Edit, Delete Geometrics | Leaflet- Draw Plugin | GeoDev. 464 views 10 days ago. GeoDev.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m afraid I can’t really help you here. Being a folium maintainer doesn’t mean I develop all new features that are requested.
One thing to keep in mind that in general folium is a one-way street from Python to Javascript, so if you want to get it back in Python that’s tricky.
The suggestion to use
drawnItems
makes sense. Maybe you can write some Javascript and add it to the template that stores it to disk any time a change is made or something.I’m going to close this issue since it goes a bit beyond the scope of folium. If somebody has more insight on this, or wants to share some code snippets, please do share them though!