question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get layer data from polygons in Draw plugin

See original GitHub issue
from 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Conengmocommented, Mar 26, 2021

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.

0reactions
Conengmocommented, Nov 22, 2022

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found