Skip to content

Commit daa99b0

Browse files
author
Ingeborg Gjerde
committed
add tooltip and size options to map plot
1 parent 8acac06 commit daa99b0

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/field_manager_api/utils/folium_plotter.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@
33

44

55
class MapHandler:
6-
def __init__(self, locations):
6+
def __init__(self, locations, height="300px", width="100%", tiles="OpenTopoMap"):
77
"""
88
Initialize the MapHandler with a list of locations.
99
Each location should be a dictionary containing 'lat', 'lon', and optionally 'name', 'depth_base', and 'predictions'.
1010
"""
1111
self.locations = locations
12+
figure = folium.Figure(
13+
width=width, height=height
14+
) # Adjust the dimensions as needed
1215
self.map = folium.Map(
13-
location=[locations[0].lat, locations[0].lon], zoom_start=18
16+
location=[locations[0].lat, locations[0].lon], zoom_start=18, tiles=tiles
1417
)
18+
self.map.add_to(figure)
1519

1620
def plot_locations(self):
1721
"""Plot markers for each location on the map."""
18-
for location in self.locations:
22+
for ix, location in enumerate(self.locations):
1923
folium.Marker(
2024
location=[location.lat, location.lon],
25+
tooltip=location.get_html_description(location_ix=ix),
2126
popup=location.name,
27+
icon=folium.Icon(icon="asterisk", prefix="fa", color="blue"),
2228
).add_to(self.map)
2329
return self.map
2430

0 commit comments

Comments
 (0)