add ruby map layer to map ojb
This commit is contained in:
@ -13,13 +13,14 @@ class MapRenderer:
|
||||
"""Initialize map renderer."""
|
||||
pass
|
||||
|
||||
def create_route_map(self, points, start_point, end_point):
|
||||
def create_route_map(self, points, start_point, end_point, tile_layer='OpenStreetMap'):
|
||||
"""Create an interactive map with the hiking route.
|
||||
|
||||
Args:
|
||||
points: List of (latitude, longitude) tuples for the route
|
||||
start_point: (latitude, longitude) tuple for start
|
||||
end_point: (latitude, longitude) tuple for end
|
||||
tile_layer: Map tile layer to use ('OpenStreetMap' or 'RudyMap')
|
||||
|
||||
Returns:
|
||||
folium.Map: Interactive map object
|
||||
@ -31,13 +32,36 @@ class MapRenderer:
|
||||
center_lat = sum(p[0] for p in points) / len(points)
|
||||
center_lon = sum(p[1] for p in points) / len(points)
|
||||
|
||||
# Create map centered on the route
|
||||
# Create map ojb
|
||||
route_map = folium.Map(
|
||||
location=[center_lat, center_lon],
|
||||
zoom_start=13,
|
||||
tiles='OpenStreetMap',
|
||||
tiles=None, # Don't add default tiles, we'll add custom ones
|
||||
)
|
||||
|
||||
# Add OpenStreetMap layer
|
||||
folium.TileLayer(
|
||||
tiles='OpenStreetMap',
|
||||
name='OpenStreetMap',
|
||||
overlay=False,
|
||||
control=True,
|
||||
show=tile_layer == 'OpenStreetMap',
|
||||
).add_to(route_map)
|
||||
|
||||
# Add Rudy Map (魯地圖) layer
|
||||
folium.TileLayer(
|
||||
tiles='https://tile.happyman.idv.tw/map/moi_osm/{z}/{x}/{y}.png',
|
||||
attr='© <a href="https://rudy.basecamp.tw/">魯地圖</a>',
|
||||
name='魯地圖 (Rudy Map)',
|
||||
overlay=False,
|
||||
control=True,
|
||||
show=tile_layer == 'RudyMap',
|
||||
max_zoom=18,
|
||||
).add_to(route_map)
|
||||
|
||||
# Add layer control to switch between maps
|
||||
folium.LayerControl(position='topright').add_to(route_map)
|
||||
|
||||
# Add the route as a red polyline
|
||||
folium.PolyLine(
|
||||
locations=points,
|
||||
|
||||
Reference in New Issue
Block a user