alihmaou commited on
Commit
b40a27c
·
verified ·
1 Parent(s): 354663d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -34,7 +34,13 @@ point_info = st.sidebar.empty()
34
  map_center = [48.8566, 2.3522]
35
  m = folium.Map(location=map_center, zoom_start=13)
36
 
37
- # Fonction de callback pour les clics sur la carte
 
 
 
 
 
 
38
  def add_marker_and_polygon(lat, lon):
39
  gdf = getinfo(lat, lon)
40
  info = gdf['info'].iloc[0]
@@ -56,17 +62,11 @@ def add_marker_and_polygon(lat, lon):
56
  {info}
57
  """)
58
 
59
- # Ajout d'un callback sur les clics de la carte
60
- m.add_child(folium.LatLngPopup())
61
-
62
- # Affichage de la carte
63
- st_map = st_folium(m, width=700, height=500)
64
-
65
  # Si un clic est détecté, mettre à jour la carte et les informations
66
- if st_map['last_clicked']:
67
  lat = st_map['last_clicked']['lat']
68
  lon = st_map['last_clicked']['lng']
69
  add_marker_and_polygon(lat, lon)
70
 
71
- # Afficher la carte
72
  st_map = st_folium(m, width=700, height=500)
 
34
  map_center = [48.8566, 2.3522]
35
  m = folium.Map(location=map_center, zoom_start=13)
36
 
37
+ # Ajout d'un callback sur les clics de la carte
38
+ m.add_child(folium.LatLngPopup())
39
+
40
+ # Affichage de la carte
41
+ st_map = st_folium(m, width=700, height=500)
42
+
43
+ # Fonction pour ajouter un marqueur et un polygone sur la carte
44
  def add_marker_and_polygon(lat, lon):
45
  gdf = getinfo(lat, lon)
46
  info = gdf['info'].iloc[0]
 
62
  {info}
63
  """)
64
 
 
 
 
 
 
 
65
  # Si un clic est détecté, mettre à jour la carte et les informations
66
+ if st_map and 'last_clicked' in st_map and st_map['last_clicked']:
67
  lat = st_map['last_clicked']['lat']
68
  lon = st_map['last_clicked']['lng']
69
  add_marker_and_polygon(lat, lon)
70
 
71
+ # Afficher la carte mise à jour
72
  st_map = st_folium(m, width=700, height=500)