|
3 | 3 |
|
4 | 4 |
|
5 | 5 | class MapHandler: |
6 | | - def __init__(self, locations): |
| 6 | + def __init__(self, locations, height="300px", width="100%", tiles="OpenTopoMap"): |
7 | 7 | """ |
8 | 8 | Initialize the MapHandler with a list of locations. |
9 | 9 | Each location should be a dictionary containing 'lat', 'lon', and optionally 'name', 'depth_base', and 'predictions'. |
10 | 10 | """ |
11 | 11 | self.locations = locations |
| 12 | + figure = folium.Figure( |
| 13 | + width=width, height=height |
| 14 | + ) # Adjust the dimensions as needed |
12 | 15 | 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 |
14 | 17 | ) |
| 18 | + self.map.add_to(figure) |
15 | 19 |
|
16 | 20 | def plot_locations(self): |
17 | 21 | """Plot markers for each location on the map.""" |
18 | | - for location in self.locations: |
| 22 | + for ix, location in enumerate(self.locations): |
19 | 23 | folium.Marker( |
20 | 24 | location=[location.lat, location.lon], |
| 25 | + tooltip=location.get_html_description(location_ix=ix), |
21 | 26 | popup=location.name, |
| 27 | + icon=folium.Icon(icon="asterisk", prefix="fa", color="blue"), |
22 | 28 | ).add_to(self.map) |
23 | 29 | return self.map |
24 | 30 |
|
|
0 commit comments