Spaces:
Runtime error
Runtime error
Commit
·
caddedc
1
Parent(s):
6995ee2
update markers (#2)
Browse files- update markers (57ede3a1aaecafd15a195d7c50cc5039e94d482e)
Co-authored-by: Loubna Ben Allal <[email protected]>
app.py
CHANGED
|
@@ -43,32 +43,6 @@ df = parse_gg_sheet(
|
|
| 43 |
)
|
| 44 |
|
| 45 |
|
| 46 |
-
def display_tab(input):
|
| 47 |
-
m = folium.Map(
|
| 48 |
-
location=[31.628674, -7.992047],
|
| 49 |
-
zoom_start=8.5,
|
| 50 |
-
min_zoom=8.5,
|
| 51 |
-
max_lat=35.628674,
|
| 52 |
-
min_lat=29.628674,
|
| 53 |
-
max_lon=-4.992047,
|
| 54 |
-
min_lon=-10.992047,
|
| 55 |
-
max_bounds=True,
|
| 56 |
-
)
|
| 57 |
-
filtered_df = df[df[' What are your needs? / ما هي احتياجاتك؟ (أضفها إذا لم يتم ذكرها)'] == input]
|
| 58 |
-
|
| 59 |
-
for index, row in filtered_df.iterrows():
|
| 60 |
-
if row["latlng"] is None:
|
| 61 |
-
continue
|
| 62 |
-
folium.Marker(
|
| 63 |
-
location=row["latlng"],
|
| 64 |
-
tooltip=row[' لأي قيادة / دوار تنتمون ؟'] if not pd.isna(row[' لأي قيادة / دوار تنتمون ؟']) else None,
|
| 65 |
-
popup=row["رقم الهاتف (اختياري)"] if not pd.isna(row["رقم الهاتف (اختياري)"]) else None,
|
| 66 |
-
).add_to(m)
|
| 67 |
-
st_folium(m, use_container_width=True)
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
# request_type = st.selectbox('Choose request type/اختر نوع الطلب', ("إغاثة", "مساعدة طبية", "مأوى", "طعام وماء", "مخاطر (تسرب الغاز، تلف في الخدمات العامة...)"))
|
| 71 |
-
|
| 72 |
headers_mapping = {
|
| 73 |
"إغاثة": "Rescue/إغاثة",
|
| 74 |
"مساعدة طبية": "Medical Assistance/مساعدة طبية",
|
|
@@ -76,6 +50,13 @@ headers_mapping = {
|
|
| 76 |
"طعام وماء": "Food & Water/طعام وماء",
|
| 77 |
"مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "Danger/مخاطر",
|
| 78 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
options = ["إغاثة", "مساعدة طبية", "مأوى", "طعام وماء", "مخاطر (تسرب الغاز، تلف في الخدمات العامة...)"]
|
| 80 |
selected_options = []
|
| 81 |
|
|
@@ -89,7 +70,7 @@ for i, option in enumerate(options):
|
|
| 89 |
if checked:
|
| 90 |
selected_options.append(option)
|
| 91 |
|
| 92 |
-
|
| 93 |
filtered_df = df[df[' What are your needs? / ما هي احتياجاتك؟ (أضفها إذا لم يتم ذكرها)'].isin(selected_options)]
|
| 94 |
selected_headers = [headers_mapping[request] for request in selected_options]
|
| 95 |
st.subheader(", ".join(selected_headers))
|
|
@@ -105,13 +86,18 @@ m = folium.Map(
|
|
| 105 |
max_bounds=True,
|
| 106 |
)
|
| 107 |
|
|
|
|
| 108 |
for index, row in filtered_df.iterrows():
|
|
|
|
|
|
|
|
|
|
| 109 |
if row["latlng"] is None:
|
| 110 |
continue
|
| 111 |
folium.Marker(
|
| 112 |
location=row["latlng"],
|
| 113 |
tooltip=row[' لأي قيادة / دوار تنتمون ؟'] if not pd.isna(row[' لأي قيادة / دوار تنتمون ؟']) else None,
|
| 114 |
-
popup=
|
|
|
|
| 115 |
).add_to(m)
|
| 116 |
st_data = st_folium(m, use_container_width=True)
|
| 117 |
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
headers_mapping = {
|
| 47 |
"إغاثة": "Rescue/إغاثة",
|
| 48 |
"مساعدة طبية": "Medical Assistance/مساعدة طبية",
|
|
|
|
| 50 |
"طعام وماء": "Food & Water/طعام وماء",
|
| 51 |
"مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "Danger/مخاطر",
|
| 52 |
}
|
| 53 |
+
colors_mapping = {
|
| 54 |
+
"إغاثة": "red",
|
| 55 |
+
"مساعدة طبية": "orange",
|
| 56 |
+
"مأوى": "yellow",
|
| 57 |
+
"طعام وماء": "blue",
|
| 58 |
+
"مخاطر (تسرب الغاز، تلف في الخدمات العامة...)": "grey",
|
| 59 |
+
}
|
| 60 |
options = ["إغاثة", "مساعدة طبية", "مأوى", "طعام وماء", "مخاطر (تسرب الغاز، تلف في الخدمات العامة...)"]
|
| 61 |
selected_options = []
|
| 62 |
|
|
|
|
| 70 |
if checked:
|
| 71 |
selected_options.append(option)
|
| 72 |
|
| 73 |
+
df['id'] = df.index
|
| 74 |
filtered_df = df[df[' What are your needs? / ما هي احتياجاتك؟ (أضفها إذا لم يتم ذكرها)'].isin(selected_options)]
|
| 75 |
selected_headers = [headers_mapping[request] for request in selected_options]
|
| 76 |
st.subheader(", ".join(selected_headers))
|
|
|
|
| 86 |
max_bounds=True,
|
| 87 |
)
|
| 88 |
|
| 89 |
+
|
| 90 |
for index, row in filtered_df.iterrows():
|
| 91 |
+
request_type = row[' What are your needs? / ما هي احتياجاتك؟ (أضفها إذا لم يتم ذكرها)']
|
| 92 |
+
phone = row["رقم الهاتف (اختياري)"] if not pd.isna(row["رقم الهاتف (اختياري)"]) else ""
|
| 93 |
+
display_text = f"{request_type} {phone}"
|
| 94 |
if row["latlng"] is None:
|
| 95 |
continue
|
| 96 |
folium.Marker(
|
| 97 |
location=row["latlng"],
|
| 98 |
tooltip=row[' لأي قيادة / دوار تنتمون ؟'] if not pd.isna(row[' لأي قيادة / دوار تنتمون ؟']) else None,
|
| 99 |
+
popup=display_text,
|
| 100 |
+
icon=folium.Icon(colors_mapping[request_type])
|
| 101 |
).add_to(m)
|
| 102 |
st_data = st_folium(m, use_container_width=True)
|
| 103 |
|