zheng.tang commited on
Commit
0689b5c
1 Parent(s): a607534

添加 folium.plugins和streamlit_folium

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import streamlit as st
2
  import folium
 
 
3
  import json
4
 
5
  # Set the map center and zoom level
@@ -10,15 +12,15 @@ ZOOM_LEVEL = 10
10
  m = folium.Map(location=MAP_CENTER, zoom_start=ZOOM_LEVEL)
11
 
12
  # Create a DrawControl object
13
- dc = folium.plugins.DrawControl()
14
 
15
  # Set the draw options to allow only polygons and rectangles
16
- dc.draw_options = {
17
- "polyline": False,
18
- "circle": False,
19
- "circlemarker": False,
20
- "marker": False,
21
- }
22
 
23
  # Set the edit options to allow editing and deleting
24
  dc.edit_options = {
@@ -56,8 +58,8 @@ m.add_child(folium.Element("map.on('draw:edited', handleDrawEvent);"))
56
  # Display the folium map using streamlit
57
  st_folium(m)
58
 
59
- # Get the geojson data from Streamlit
60
- geojson = st_folium.get_value()
61
 
62
- # Display the geojson data using streamlit
63
- st.write(geojson)
 
1
  import streamlit as st
2
  import folium
3
+ import folium.plugins
4
+ from streamlit_folium import st_folium
5
  import json
6
 
7
  # Set the map center and zoom level
 
12
  m = folium.Map(location=MAP_CENTER, zoom_start=ZOOM_LEVEL)
13
 
14
  # Create a DrawControl object
15
+ dc = folium.plugins.Draw()
16
 
17
  # Set the draw options to allow only polygons and rectangles
18
+ # dc.draw_options = {
19
+ # "polyline": False,
20
+ # "circle": False,
21
+ # "circlemarker": False,
22
+ # "marker": False,
23
+ # }
24
 
25
  # Set the edit options to allow editing and deleting
26
  dc.edit_options = {
 
58
  # Display the folium map using streamlit
59
  st_folium(m)
60
 
61
+ # # Get the geojson data from Streamlit
62
+ # geojson = st_folium.get_value()
63
 
64
+ # # Display the geojson data using streamlit
65
+ # st.write(geojson)