fixes route drawing
This commit is contained in:
@@ -125,9 +125,14 @@ export class LayerManager {
|
|||||||
this.map.on('mouseleave', id, listener.onLeave);
|
this.map.on('mouseleave', id, listener.onLeave);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listener.onMouseDown && !this.addedListeners.has("click-" + id)) {
|
if (listener.onMouseDown && !this.addedListeners.has("mousedown-" + id)) {
|
||||||
this.addedListeners.add("click-" + id)
|
this.addedListeners.add("mousedown-" + id)
|
||||||
this.map.on('click', id, listener.onMouseDown);
|
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)) {
|
if (listener.onMouseMove && !this.addedListeners.has("mousemove-" + id)) {
|
||||||
@@ -188,7 +193,7 @@ export class LayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private restoreLayers() {
|
private restoreLayers() {
|
||||||
for (const [id, layer] of Object.entries(this.layers)) {
|
for (const [id, layer] of Object.entries(this.layers)) {
|
||||||
this.addLayer(id, layer)
|
this.addLayer(id, layer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 { createOverpassPopup } from "$lib/util/maplibre_util";
|
||||||
import * as M from "maplibre-gl";
|
import * as M from "maplibre-gl";
|
||||||
import { type LngLatBounds, type MapMouseEvent, type StyleSpecification } from "maplibre-gl";
|
import { type LngLatBounds, type MapMouseEvent, type StyleSpecification } from "maplibre-gl";
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ export class TrailLayer implements BaseLayer {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.listeners = { id: listerners ?? {} }
|
this.listeners = { [id]: listerners ?? {} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -811,9 +811,7 @@
|
|||||||
if (previousRouteSegment) {
|
if (previousRouteSegment) {
|
||||||
editRoute(anchorIndex - 1, previousRouteSegment);
|
editRoute(anchorIndex - 1, previousRouteSegment);
|
||||||
}
|
}
|
||||||
if ($formData.expand?.gpx_data) {
|
updateTrailWithRouteData();
|
||||||
updateTrailWithRouteData();
|
|
||||||
}
|
|
||||||
normalizeRouteTime();
|
normalizeRouteTime();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -1044,10 +1042,10 @@
|
|||||||
overwriteGPX = true;
|
overwriteGPX = true;
|
||||||
updateTotals(valhallaStore.route);
|
updateTotals(valhallaStore.route);
|
||||||
|
|
||||||
updateTrailOnMap();
|
|
||||||
if (!$formData.id) {
|
if (!$formData.id) {
|
||||||
$formData.id = cryptoRandomString({ length: 15 });
|
$formData.id = cryptoRandomString({ length: 15 });
|
||||||
}
|
}
|
||||||
|
updateTrailOnMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTotals(gpx: GPX) {
|
function updateTotals(gpx: GPX) {
|
||||||
@@ -1061,7 +1059,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTrailOnMap() {
|
function updateTrailOnMap() {
|
||||||
const t: Trail = JSON.parse(JSON.stringify($formData));
|
const t: Trail = JSON.parse(JSON.stringify($formData));
|
||||||
t.expand!.gpx = valhallaStore.route;
|
t.expand!.gpx = valhallaStore.route;
|
||||||
mapTrail = [t];
|
mapTrail = [t];
|
||||||
|
|||||||
Reference in New Issue
Block a user