Give trail pages an outdoor map
Trail maps now open on an outdoor style of our own, drawn on the same OpenFreeMap tiles: hill shading and contour lines from the public Terrain Tiles, woods, water, footpaths, and peaks with their heights. Heights and contours follow the visitor's units. A switch on the map goes back to the plain map and is remembered. The home page's overview map is unchanged. If the elevation tiles or the contour script fail, the map still loads without them. The security policy allows the one elevation-tile path. The contour add-on (maplibre-contour 0.1.1) is vendored with its licence, and the elevation data is credited on the map, under it and in the footer. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
540a3220be
commit
ad2223f427
15 files changed
+994
-27
No files matched your search
+5
-4
@@ -9,6 +9,7 @@ import re
|
||||
import urllib.parse
|
||||
|
||||
from . import common, elevation, facets, hike, words
|
||||
from .layout import OUTDOOR_STYLE
|
||||
from .markup import Markup, esc
|
||||
|
||||
EXTRACT_SOURCES = {"osm": "OpenStreetMap", "usfs": "USDA Forest Service", "nps": "National Park Service"}
|
||||
@@ -307,7 +308,7 @@ def map_figure(rec):
|
||||
bbox = rec["derived"].get("map_bbox") or rec["derived"].get("bbox")
|
||||
bbox_attr = f' data-bbox="{",".join(str(v) for v in bbox)}"' if bbox else ""
|
||||
credit = common.sentence(common.credit_text(src.get("attribution", "")))
|
||||
return f"""<figure class="mapfig mapfig--detail detail__map" data-map="trail" data-src="/trails/{esc(rec["id"])}/map.json" data-route="{"yes" if route else "no"}"{bbox_attr}>
|
||||
return f"""<figure class="mapfig mapfig--detail detail__map" data-map="trail" data-src="/trails/{esc(rec["id"])}/map.json" data-route="{"yes" if route else "no"}"{bbox_attr} data-outdoor="{OUTDOOR_STYLE}">
|
||||
<div class="mapfig__frame">
|
||||
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true"></span>
|
||||
<div class="map" role="region" aria-label="Map of the {esc(rec["name"])}">
|
||||
@@ -319,7 +320,7 @@ def map_figure(rec):
|
||||
</div>
|
||||
<figcaption class="mapfig__caption">
|
||||
<ul class="legend" aria-label="Legend">{legend}</ul>
|
||||
<p>Track: {esc(src.get("line_source", ""))}, read {esc(src.get("source_checked", ""))}, drawn simplified to 30 m. Credit: {esc(credit)} Base map: OpenFreeMap, © OpenMapTiles, data © OpenStreetMap contributors.</p>
|
||||
<p>Track: {esc(src.get("line_source", ""))}, read {esc(src.get("source_checked", ""))}, drawn simplified to 30 m. Credit: {esc(credit)} {common.TRAIL_MAP_CREDIT}</p>
|
||||
</figcaption>
|
||||
</figure>"""
|
||||
|
||||
@@ -476,7 +477,7 @@ def sketch_figure(rec):
|
||||
legend_text = "No GPX here: start only"
|
||||
_title, status, reason, rule, actions_html = _no_gpx_parts(rec)
|
||||
reason_html = reason if isinstance(reason, Markup) else common.rich(reason)
|
||||
return f"""<figure class="mapfig mapfig--detail detail__map" id="track" data-map="sketch" data-src="/trails/{esc(rec["id"])}/sketch.json" data-route="{"yes" if route else "no"}"{bbox_attr}>
|
||||
return f"""<figure class="mapfig mapfig--detail detail__map" id="track" data-map="sketch" data-src="/trails/{esc(rec["id"])}/sketch.json" data-route="{"yes" if route else "no"}"{bbox_attr} data-outdoor="{OUTDOOR_STYLE}">
|
||||
<div class="mapfig__frame">
|
||||
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true"></span>
|
||||
<div class="map" role="region" aria-label="Map showing the start and end of the {esc(rec["name"])}; no GPX here">
|
||||
@@ -493,7 +494,7 @@ def sketch_figure(rec):
|
||||
<p>{reason_html}</p>
|
||||
<p class="note">{esc(rule)}</p>
|
||||
{actions_html}
|
||||
<p>Base map: OpenFreeMap, © OpenMapTiles, data © OpenStreetMap contributors.</p>
|
||||
<p>{common.TRAIL_MAP_CREDIT}</p>
|
||||
</div>
|
||||
</figcaption>
|
||||
</figure>"""
|
||||
|
||||
Reference in new issue
Block a user