-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathissue_1770.py
More file actions
46 lines (38 loc) · 1.26 KB
/
issue_1770.py
File metadata and controls
46 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import json
import streamlit as st
from streamlit_folium import st_folium
import folium
st.set_page_config(layout="wide")
geojson = """
{"type": "FeatureCollection",
"features": [
{"id": "0", "type": "Feature", "properties": {"foo": 0},
"geometry": {"type": "Point", "coordinates": [0.0, 0.0]}
},
{"id": "1", "type": "Feature", "properties": {"foo": 1},
"geometry": {"type": "MultiPoint", "coordinates": [[1.0, 1.0]]}},
{"id": "2", "type": "Feature",
"properties": {"foo": 2}, "geometry": {"type": "MultiPoint", "coordinates":
[[2.0, 2.0]]}}, {"id": "3", "type": "Feature", "properties": {"foo": 3},
"geometry": {"type": "MultiPoint", "coordinates": [[3.0, 3.0]]}}, {"id": "4",
"type": "Feature", "properties": {"foo": 4}, "geometry": {"type":
"MultiPoint", "coordinates": [[4.0, 4.0]]}}]}"""
geojson = json.loads(geojson)
on_each_feature = folium.JsCode(
"""
(feature, layer) => {
layer.bindPopup("hello world");
}
"""
)
m = folium.Map(
zoom_start=5,
location=(0, 0),
)
folium.GeoJson(
geojson, on_each_feature=on_each_feature, marker=folium.CircleMarker(radius=20)
).add_to(m)
st_folium(m, width=700, height=500)
# st_folium(m, width=700, height=500, returned_objects=[])
html = m.get_root().render()
st.code(html)