Spaces:
Sleeping
Sleeping
pjgerrits
commited on
Commit
·
67ac20d
1
Parent(s):
02ed674
map control updates and theme
Browse files- app.py +31 -26
- streamlit.toml +2 -0
app.py
CHANGED
@@ -64,23 +64,17 @@ if 'points' not in st.session_state:
|
|
64 |
st.session_state['points'] = {'start': None, 'lost': None, 'end': None}
|
65 |
if 'survey' not in st.session_state:
|
66 |
st.session_state['survey'] = False
|
|
|
|
|
67 |
|
68 |
# Custom CSS for colored buttons
|
69 |
st.markdown(
|
70 |
"""
|
71 |
<style>
|
72 |
-
.
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
border-radius: 5px;
|
77 |
-
cursor: pointer;
|
78 |
-
text-align: center;
|
79 |
-
color: white;
|
80 |
-
}
|
81 |
-
.start-button { background-color: red; }
|
82 |
-
.lost-button { background-color: orange; }
|
83 |
-
.end-button { background-color: blue; }
|
84 |
</style>
|
85 |
""",
|
86 |
unsafe_allow_html=True,
|
@@ -89,35 +83,46 @@ st.markdown(
|
|
89 |
st.sidebar.title("Step 1 - Add Markers")
|
90 |
|
91 |
# Custom buttons for selecting point type
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
-
|
99 |
-
st.
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
map_placeholder = st.empty()
|
106 |
|
107 |
with map_placeholder.container():
|
108 |
folium_map = create_map(st.session_state['points'])
|
109 |
-
map_output = st_folium(folium_map, width="100%", height=
|
110 |
|
111 |
new_coords = None
|
112 |
if map_output and 'last_clicked' in map_output and map_output['last_clicked'] is not None:
|
113 |
new_coords = (map_output['last_clicked']['lat'], map_output['last_clicked']['lng'])
|
114 |
|
115 |
if new_coords:
|
116 |
-
st.session_state['points'][point_type] = new_coords
|
117 |
map_placeholder.empty()
|
118 |
with map_placeholder.container():
|
119 |
folium_map = create_map(st.session_state['points'])
|
120 |
-
st_folium(folium_map, width="100%", height=
|
121 |
|
122 |
if all(st.session_state['points'].values()) and not st.session_state['survey']:
|
123 |
if st.sidebar.button("Proceed to Survey"):
|
|
|
64 |
st.session_state['points'] = {'start': None, 'lost': None, 'end': None}
|
65 |
if 'survey' not in st.session_state:
|
66 |
st.session_state['survey'] = False
|
67 |
+
if 'point_type' not in st.session_state:
|
68 |
+
st.session_state['point_type'] = 'start'
|
69 |
|
70 |
# Custom CSS for colored buttons
|
71 |
st.markdown(
|
72 |
"""
|
73 |
<style>
|
74 |
+
.start-button { background-color: red; color: white; border: none; padding: 10px 20px; margin: 5px; border-radius: 5px; cursor: pointer; }
|
75 |
+
.lost-button { background-color: orange; color: white; border: none; padding: 10px 20px; margin: 5px; border-radius: 5px; cursor: pointer; }
|
76 |
+
.end-button { background-color: blue; color: white; border: none; padding: 10px 20px; margin: 5px; border-radius: 5px; cursor: pointer; }
|
77 |
+
.reset-button { background-color: gray; color: white; border: none; padding: 10px 20px; margin: 5px; border-radius: 5px; cursor: pointer; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
</style>
|
79 |
""",
|
80 |
unsafe_allow_html=True,
|
|
|
83 |
st.sidebar.title("Step 1 - Add Markers")
|
84 |
|
85 |
# Custom buttons for selecting point type
|
86 |
+
col1, col2, col3 = st.sidebar.columns(3)
|
87 |
+
|
88 |
+
with col1:
|
89 |
+
if st.button("Start", key="start-button"):
|
90 |
+
st.session_state['point_type'] = 'start'
|
91 |
+
st.sidebar.markdown('<div class="start-button">Start</div>', unsafe_allow_html=True)
|
92 |
+
|
93 |
+
with col2:
|
94 |
+
if st.button("Lost", key="lost-button"):
|
95 |
+
st.session_state['point_type'] = 'lost'
|
96 |
+
st.sidebar.markdown('<div class="lost-button">Lost</div>', unsafe_allow_html=True)
|
97 |
|
98 |
+
with col3:
|
99 |
+
if st.button("End", key="end-button"):
|
100 |
+
st.session_state['point_type'] = 'end'
|
101 |
+
st.sidebar.markdown('<div class="end-button">End</div>', unsafe_allow_html=True)
|
102 |
+
|
103 |
+
st.sidebar.write(f"Selected Point Type: {st.session_state['point_type'].capitalize()}")
|
104 |
+
|
105 |
+
# Reset button
|
106 |
+
if st.sidebar.button("Reset Markers", key="reset-button"):
|
107 |
+
st.session_state['points'] = {'start': None, 'lost': None, 'end': None}
|
108 |
+
st.experimental_rerun()
|
109 |
|
110 |
map_placeholder = st.empty()
|
111 |
|
112 |
with map_placeholder.container():
|
113 |
folium_map = create_map(st.session_state['points'])
|
114 |
+
map_output = st_folium(folium_map, width="100%", height=800)
|
115 |
|
116 |
new_coords = None
|
117 |
if map_output and 'last_clicked' in map_output and map_output['last_clicked'] is not None:
|
118 |
new_coords = (map_output['last_clicked']['lat'], map_output['last_clicked']['lng'])
|
119 |
|
120 |
if new_coords:
|
121 |
+
st.session_state['points'][st.session_state['point_type']] = new_coords
|
122 |
map_placeholder.empty()
|
123 |
with map_placeholder.container():
|
124 |
folium_map = create_map(st.session_state['points'])
|
125 |
+
st_folium(folium_map, width="100%", height=800)
|
126 |
|
127 |
if all(st.session_state['points'].values()) and not st.session_state['survey']:
|
128 |
if st.sidebar.button("Proceed to Survey"):
|
streamlit.toml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base="dark"
|