From f898afad3356d57b9bf906ae7e207584c23536b3 Mon Sep 17 00:00:00 2001 From: Walter Dal'Maz Silva Date: Fri, 10 May 2024 10:17:04 +0200 Subject: [PATCH] Improving interface --- .gitignore | 3 +++ gpxtohtml.py | 35 ++++++++++++++++++----------------- gpxviaferrata.py | 19 ++++++++++++++++++- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 7425904..d1b346e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ # LOCAL ############################################################################## +# In case of opening as a vault. +.obsidian + # Content produced locally by Pelican. /output/ diff --git a/gpxtohtml.py b/gpxtohtml.py index f300dce..d3c2309 100644 --- a/gpxtohtml.py +++ b/gpxtohtml.py @@ -171,25 +171,26 @@ def get_bounds(coordinates): return bounds @staticmethod - def map_at_location(location, tiles): + def map_at_location(location, tiles, opts=None): """ Create map around given location with provided tiles. """ - route_map = folium.Map( - location = location, - width = "100%", - height = "100%", - left = "0%", - top = "0%", - position = "relative", - tiles = tiles.url, - attr = tiles.attribution, - crs = "EPSG3857", - control_scale= True, - prefer_canvas= False, - no_touch = True, - disable_3d = False, - png_enabled = True, - zoom_control = False + opts = opts if opts is not None else dict( + width = "100%", + height = "100%", + left = "0%", + top = "0%", + position = "relative", + crs = "EPSG3857", + control_scale = True, + prefer_canvas = False, + no_touch = True, + disable_3d = False, + png_enabled = True, + zoom_control = False ) + + route_map = folium.Map(location = location, tiles = tiles.url, + attr = tiles.attribution, **opts) + return route_map @staticmethod diff --git a/gpxviaferrata.py b/gpxviaferrata.py index b3b72a2..e1f3752 100644 --- a/gpxviaferrata.py +++ b/gpxviaferrata.py @@ -27,7 +27,24 @@ } ] -route_map = GpxToHtml.map_at_location(location, OPENTOPOMAP) +tiles = OPENTOPOMAP + +opts = dict( + width = "100%", + height = "100%", + left = "0%", + top = "0%", + position = "relative", + crs = "EPSG3857", + control_scale = True, + prefer_canvas = False, + no_touch = True, + disable_3d = False, + png_enabled = True, + zoom_control = True +) + +route_map = GpxToHtml.map_at_location(location, tiles, opts=opts) route_map.fit_bounds(bounds) cluster = MarkerCluster().add_to(route_map)