Skip to content

Commit 7b013ae

Browse files
committed
Moved snapshots to new location
Also created new screenshots due to changing tile images
1 parent 2ba54d1 commit 7b013ae

27 files changed

+571
-151
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import json
2+
3+
import streamlit as st
4+
from streamlit_folium import st_folium
5+
6+
import folium
7+
8+
st.set_page_config(layout="wide")
9+
10+
geojson = """
11+
{"type": "FeatureCollection",
12+
"features": [
13+
{"id": "0", "type": "Feature", "properties": {"foo": 0},
14+
"geometry": {"type": "Point", "coordinates": [0.0, 0.0]}
15+
},
16+
{"id": "1", "type": "Feature", "properties": {"foo": 1},
17+
"geometry": {"type": "MultiPoint", "coordinates": [[1.0, 1.0]]}},
18+
{"id": "2", "type": "Feature",
19+
"properties": {"foo": 2}, "geometry": {"type": "MultiPoint", "coordinates":
20+
[[2.0, 2.0]]}}, {"id": "3", "type": "Feature", "properties": {"foo": 3},
21+
"geometry": {"type": "MultiPoint", "coordinates": [[3.0, 3.0]]}}, {"id": "4",
22+
"type": "Feature", "properties": {"foo": 4}, "geometry": {"type":
23+
"MultiPoint", "coordinates": [[4.0, 4.0]]}}]}"""
24+
25+
geojson = json.loads(geojson)
26+
27+
on_each_feature = folium.JsCode(
28+
"""
29+
(feature, layer) => {
30+
layer.bindPopup("hello world");
31+
}
32+
"""
33+
)
34+
m = folium.Map(
35+
zoom_start=5,
36+
location=(0, 0),
37+
)
38+
folium.GeoJson(
39+
geojson, on_each_feature=on_each_feature, marker=folium.CircleMarker(radius=20)
40+
).add_to(m)
41+
42+
st_folium(m, width=700, height=500)
43+
# st_folium(m, width=700, height=500, returned_objects=[])
44+
45+
html = m.get_root().render()
46+
st.code(html)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import io
2+
3+
import branca
4+
import geopandas
5+
import pandas as pd
6+
import requests
7+
import streamlit as st
8+
from streamlit_folium import st_folium
9+
10+
import folium
11+
12+
st.set_page_config(layout="wide")
13+
14+
response = requests.get(
15+
"https://gist.githubusercontent.com/tvpmb/4734703/raw/"
16+
"b54d03154c339ed3047c66fefcece4727dfc931a/US%2520State%2520List"
17+
)
18+
abbrs = pd.read_json(io.StringIO(response.text))
19+
20+
income = pd.read_csv(
21+
"https://raw.githubusercontent.com/pri-data/50-states/master/data/income-counties-states-national.csv",
22+
dtype={"fips": str},
23+
)
24+
income["income-2015"] = pd.to_numeric(income["income-2015"], errors="coerce")
25+
26+
data = requests.get(
27+
"https://raw.githubusercontent.com/python-visualization/folium-example-data/main/us_states.json"
28+
).json()
29+
30+
states = geopandas.GeoDataFrame.from_features(data, crs="EPSG:4326")
31+
statesmerge = states.merge(abbrs, how="left", left_on="name", right_on="name")
32+
statesmerge["geometry"] = statesmerge.geometry.simplify(0.05)
33+
34+
statesmerge["medianincome"] = statesmerge.merge(
35+
income.groupby("state")["income-2015"].median(),
36+
how="left",
37+
left_on="alpha-2",
38+
right_on="state",
39+
)["income-2015"]
40+
statesmerge["change"] = statesmerge.merge(
41+
income.groupby("state")["change"].median(),
42+
how="left",
43+
left_on="alpha-2",
44+
right_on="state",
45+
)["change"]
46+
47+
statesmerge["empty"] = None
48+
49+
colormap = branca.colormap.LinearColormap(
50+
vmin=statesmerge["change"].quantile(0.0),
51+
vmax=statesmerge["change"].quantile(1),
52+
colors=["red", "orange", "lightblue", "green", "darkgreen"],
53+
caption="State Level Median County Household Income (%)",
54+
)
55+
56+
m = folium.Map(location=[35.3, -97.6], zoom_start=4)
57+
58+
popup = folium.GeoJsonPopup(
59+
fields=["name", "change"],
60+
aliases=["State", "% Change"],
61+
localize=True,
62+
labels=True,
63+
style="background-color: yellow;",
64+
)
65+
66+
tooltip = folium.GeoJsonTooltip(
67+
fields=["name", "medianincome", "change", "empty"],
68+
aliases=["State:", "2015 Median Income(USD):", "Median % Change:", "empty"],
69+
localize=True,
70+
sticky=False,
71+
labels=True,
72+
style="""
73+
background-color: #F0EFEF;
74+
border: 2px solid black;
75+
border-radius: 3px;
76+
box-shadow: 3px;
77+
""",
78+
max_width=800,
79+
)
80+
81+
g = folium.GeoJson(
82+
statesmerge,
83+
style_function=lambda x: {
84+
"fillColor": (
85+
colormap(x["properties"]["change"])
86+
if x["properties"]["change"] is not None
87+
else "transparent"
88+
),
89+
"color": "black",
90+
"fillOpacity": 0.4,
91+
},
92+
tooltip=tooltip,
93+
popup=popup,
94+
).add_to(m)
95+
96+
colormap.add_to(m)
97+
98+
html = m.get_root().render()
99+
st_folium(m, width=700, height=500)
100+
101+
st.code(html)

folium/map.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ def add_child(self, child, name=None, index=None):
445445
self.set_icon(child)
446446
else:
447447
super().add_child(child, name, index)
448+
return self
448449

449450

450451
class Popup(MacroElement):

tests/playwright/regressions/main.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/playwright/regressions/pages/issue_1885.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/playwright/regressions/pages/issue_1885_add_child.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/playwright/regressions/pages/issue_1885_add_to.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/playwright/regressions/pages/issue_1885_set_icon.py

Lines changed: 0 additions & 31 deletions
This file was deleted.
-569 Bytes
Binary file not shown.

tests/playwright/regressions/static/book-open-variant-outline.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)