Spaces:
Sleeping
Sleeping
place a marker where the last click was
Browse files
app.py
CHANGED
@@ -261,12 +261,9 @@ def main():
|
|
261 |
amsterdam_coords = [52.3676, 4.9041]
|
262 |
m = folium.Map(location=amsterdam_coords, zoom_start=13)
|
263 |
|
264 |
-
#
|
265 |
-
folium.Marker
|
266 |
-
|
267 |
-
popup="Amsterdam City Center",
|
268 |
-
icon=folium.Icon(color="red", icon="info-sign")
|
269 |
-
).add_to(m)
|
270 |
|
271 |
# Display the map and get clicked coordinates
|
272 |
map_data = st_folium(m, height=400, width=700)
|
@@ -276,6 +273,14 @@ def main():
|
|
276 |
lat = map_data['last_clicked']['lat']
|
277 |
lng = map_data['last_clicked']['lng']
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
st.write(f"Selected coordinates: {lat:.4f}, {lng:.4f}")
|
280 |
|
281 |
# Get nearest Mapillary image
|
|
|
261 |
amsterdam_coords = [52.3676, 4.9041]
|
262 |
m = folium.Map(location=amsterdam_coords, zoom_start=13)
|
263 |
|
264 |
+
# Create a LayerGroup for the marker
|
265 |
+
marker_group = folium.FeatureGroup(name="Marker")
|
266 |
+
m.add_child(marker_group)
|
|
|
|
|
|
|
267 |
|
268 |
# Display the map and get clicked coordinates
|
269 |
map_data = st_folium(m, height=400, width=700)
|
|
|
273 |
lat = map_data['last_clicked']['lat']
|
274 |
lng = map_data['last_clicked']['lng']
|
275 |
|
276 |
+
# Clear previous markers and add new one
|
277 |
+
marker_group.clear()
|
278 |
+
marker_group.add_child(folium.Marker(
|
279 |
+
[lat, lng],
|
280 |
+
popup=f"Selected Location\n{lat:.4f}, {lng:.4f}",
|
281 |
+
icon=folium.Icon(color="red", icon="info-sign")
|
282 |
+
))
|
283 |
+
|
284 |
st.write(f"Selected coordinates: {lat:.4f}, {lng:.4f}")
|
285 |
|
286 |
# Get nearest Mapillary image
|