Spaces:
Runtime error
Runtime error
adding current location
Browse files- src/utils.py +19 -2
src/utils.py
CHANGED
@@ -2,7 +2,7 @@ import folium
|
|
2 |
import pandas as pd
|
3 |
from folium import plugins
|
4 |
from src.map_utils import legend_macro
|
5 |
-
|
6 |
|
7 |
EPICENTER_LOCATION = [31.12210171476489, -8.42945837915193]
|
8 |
BORDER_COLOR = "black"
|
@@ -70,6 +70,18 @@ def add_epicentre_to_map(map_obj):
|
|
70 |
popup="Epicenter مركز الزلزال",
|
71 |
icon=icon_epicentre).add_to(map_obj)
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
def add_danger_distances_to_map(map_obj):
|
75 |
Danger_Distances_group = folium.FeatureGroup(name='Danger distances - earthquake magnitude 7 | مسافات الخطر - قوة الزلازل 7').add_to(map_obj)
|
@@ -133,7 +145,12 @@ def init_map():
|
|
133 |
# Add danger zones
|
134 |
add_epicentre_to_map(m)
|
135 |
add_danger_distances_to_map(m)
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
137 |
# Add a LayerControl to the map to toggle between layers (Satellite View and Default One)
|
138 |
folium.LayerControl().add_to(m)
|
139 |
|
|
|
2 |
import pandas as pd
|
3 |
from folium import plugins
|
4 |
from src.map_utils import legend_macro
|
5 |
+
import geocoder
|
6 |
|
7 |
EPICENTER_LOCATION = [31.12210171476489, -8.42945837915193]
|
8 |
BORDER_COLOR = "black"
|
|
|
70 |
popup="Epicenter مركز الزلزال",
|
71 |
icon=icon_epicentre).add_to(map_obj)
|
72 |
|
73 |
+
def add_current_location(map_obj, current_location):
|
74 |
+
icon_current_location = folium.plugins.BeautifyIcon(
|
75 |
+
icon='spinner',
|
76 |
+
spin=True,
|
77 |
+
border_color='#0719FD',
|
78 |
+
background_color='#0719FD',
|
79 |
+
text_color='white'
|
80 |
+
)
|
81 |
+
folium.Marker(location=current_location,
|
82 |
+
popup="Your location موقعك",
|
83 |
+
icon=icon_current_location).add_to(map_obj)
|
84 |
+
|
85 |
|
86 |
def add_danger_distances_to_map(map_obj):
|
87 |
Danger_Distances_group = folium.FeatureGroup(name='Danger distances - earthquake magnitude 7 | مسافات الخطر - قوة الزلازل 7').add_to(map_obj)
|
|
|
145 |
# Add danger zones
|
146 |
add_epicentre_to_map(m)
|
147 |
add_danger_distances_to_map(m)
|
148 |
+
|
149 |
+
# Add current location to the map
|
150 |
+
g = geocoder.ip('me')
|
151 |
+
current_location = g.latlng
|
152 |
+
add_current_location(m, current_location)
|
153 |
+
|
154 |
# Add a LayerControl to the map to toggle between layers (Satellite View and Default One)
|
155 |
folium.LayerControl().add_to(m)
|
156 |
|