feat: add per-trip use_gpx and autoconnect toggles
Adds two configurable toggles to the trip blueprint (Admin2 Trip tab): - use_gpx: show/hide GPX tracks on all maps (default: enabled) - autoconnect: draw connector lines between markers (default: enabled) When use_gpx is off, GPX files are not fetched or rendered on any map (home, map, trip, dailies). The stats panel in trip.html.twig still reads GPX_URLS directly and is unaffected. When autoconnect is off, buildJourneySegments suppresses all auto-connectors; only entries with force_connect:true still draw a line — making force_connect behaviour independent of both settings. Also refactors the inline Promise.all in trip.html.twig to use the shared renderGpxJourney utility (reducing duplication). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr
This commit is contained in:
@@ -53,6 +53,8 @@
|
||||
<script>
|
||||
var FEED_ENTRIES = {{ map_entries|json_encode|raw }};
|
||||
var GPX_URLS = {{ gpx_urls|json_encode|raw }};
|
||||
var USE_GPX = {{ trip_page.header.use_gpx ?? true ? 'true' : 'false' }};
|
||||
var AUTOCONNECT = {{ trip_page.header.autoconnect ?? true ? 'true' : 'false' }};
|
||||
|
||||
var feedMap = new maplibregl.Map({
|
||||
container: 'feed-map',
|
||||
@@ -87,7 +89,7 @@ feedMap.on('load', function () {
|
||||
feedMap.fitBounds(bounds, { padding: 60, maxZoom: 11 });
|
||||
}
|
||||
|
||||
Promise.all(GPX_URLS.map(function (url, idx) {
|
||||
Promise.all((USE_GPX ? GPX_URLS : []).map(function (url) {
|
||||
return fetch(url)
|
||||
.then(function (r) { return r.text(); })
|
||||
.then(function (text) {
|
||||
@@ -101,7 +103,7 @@ feedMap.on('load', function () {
|
||||
});
|
||||
})).then(function (allTrackpoints) {
|
||||
var validTrackpoints = allTrackpoints.filter(function (tp) { return tp.length > 0; });
|
||||
var segments = MapUtils.buildJourneySegments(FEED_ENTRIES, validTrackpoints, 10);
|
||||
var segments = MapUtils.buildJourneySegments(FEED_ENTRIES, validTrackpoints, 10, { autoconnect: AUTOCONNECT });
|
||||
MapUtils.addJourneySegments(feedMap, segments, 'feed-journey');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user