fixes route drawing

This commit is contained in:
Christian Beutel
2025-08-22 13:44:37 +02:00
parent e375747422
commit 33776ad42c
4 changed files with 19 additions and 10 deletions

View File

@@ -125,9 +125,14 @@ export class LayerManager {
this.map.on('mouseleave', id, listener.onLeave);
}
if (listener.onMouseDown && !this.addedListeners.has("click-" + id)) {
this.addedListeners.add("click-" + id)
this.map.on('click', id, listener.onMouseDown);
if (listener.onMouseDown && !this.addedListeners.has("mousedown-" + id)) {
this.addedListeners.add("mousedown-" + id)
this.map.on('mousedown', id, listener.onMouseDown);
}
if (listener.onMouseUp && !this.addedListeners.has("mouseup-" + id)) {
this.addedListeners.add("mouseup-" + id)
this.map.on('mouseup', id, listener.onMouseUp);
}
if (listener.onMouseMove && !this.addedListeners.has("mousemove-" + id)) {

View File

@@ -1,3 +1,9 @@
/**
* Component adapted from: https://github.com/gpxstudio/gpx.studio/blob/main/website/src/lib/components/layer-control/OverpassLayer.ts
* Original author: @vcoppe
* License: MIT
*/
import { createOverpassPopup } from "$lib/util/maplibre_util";
import * as M from "maplibre-gl";
import { type LngLatBounds, type MapMouseEvent, type StyleSpecification } from "maplibre-gl";

View File

@@ -29,6 +29,6 @@ export class TrailLayer implements BaseLayer {
};
this.listeners = { id: listerners ?? {} }
this.listeners = { [id]: listerners ?? {} }
}
}

View File

@@ -811,9 +811,7 @@
if (previousRouteSegment) {
editRoute(anchorIndex - 1, previousRouteSegment);
}
if ($formData.expand?.gpx_data) {
updateTrailWithRouteData();
}
updateTrailWithRouteData();
normalizeRouteTime();
} catch (e) {
console.error(e);
@@ -1044,10 +1042,10 @@
overwriteGPX = true;
updateTotals(valhallaStore.route);
updateTrailOnMap();
if (!$formData.id) {
$formData.id = cryptoRandomString({ length: 15 });
}
updateTrailOnMap();
}
function updateTotals(gpx: GPX) {