diff options
-rw-r--r-- | fietsboek/__init__.py | 2 | ||||
-rw-r--r-- | fietsboek/views/tileproxy.py | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/fietsboek/__init__.py b/fietsboek/__init__.py index 21674f5..7aede7b 100644 --- a/fietsboek/__init__.py +++ b/fietsboek/__init__.py @@ -72,6 +72,8 @@ def main(global_config, **settings): settings.get('available_locales', 'en')) settings['fietsboek.pages'] = aslist( settings.get('fietsboek.pages', '')) + settings['thunderforest.maps'] = aslist( + settings.get('thunderforest.maps', '')) settings['fietsboek.default_tile_layers'] = aslist( settings.get('fietsboek.default_tile_layers', 'osm satellite osmde opentopo topplusopen opensea cycling hiking')) diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py index 42e1a67..ff68e30 100644 --- a/fietsboek/views/tileproxy.py +++ b/fietsboek/views/tileproxy.py @@ -263,6 +263,24 @@ def extract_tile_layers(settings): :rtype: list[TileSource] """ layers = [] + # Thunderforest Shortcut! + tf_api_key = settings.get("thunderforest.api_key") + if tf_api_key: + tf_access = LayerAccess(settings.get("thunderforest.access", "restricted")) + tf_attribution = ' | '.join([ + _jb_copy, + _href("https://www.thunderforest.com/", "Thunderforest"), + _href("https://www.openstreetmap.org/", "OpenStreetMap"), + ]) + for tf_map in settings["thunderforest.maps"]: + url = (f"https://tile.thunderforest.com/{tf_map}/" + f"{{z}}/{{x}}/{{y}}.png?apikey={tf_api_key}") + layers.append(TileSource( + f"tf-{tf_map}", f"TF {tf_map.title()}", url, + LayerType.BASE, 22, tf_access, tf_attribution, + )) + + # Any other custom maps for key in settings.keys(): match = re.match("^fietsboek\\.tile_layer\\.([A-Za-z0-9_-]+)$", key) if not match: |