2025-02-02 11:17:22 +01:00
|
|
|
import { get, type Readable } from 'svelte/store';
|
2026-07-24 19:06:39 +02:00
|
|
|
import {
|
2026-01-30 21:01:24 +01:00
|
|
|
type GeoJSONSource,
|
|
|
|
|
type FilterSpecification,
|
|
|
|
|
type MapLayerMouseEvent,
|
|
|
|
|
type MapLayerTouchEvent,
|
2026-07-24 19:06:39 +02:00
|
|
|
Point,
|
2026-01-30 21:01:24 +01:00
|
|
|
} from 'maplibre-gl';
|
2025-10-17 23:54:45 +02:00
|
|
|
import { map } from '$lib/components/map/map';
|
|
|
|
|
import { waypointPopup, trackpointPopup } from './gpx-layer-popup';
|
2026-10-11 11:18:36 +02:00
|
|
|
import { closestPointIndex } from '$lib/geo/closest-point';
|
2026-10-04 17:09:41 +02:00
|
|
|
import { getElevation, loadSVGIcon } from '$lib/utils';
|
2025-10-17 23:54:45 +02:00
|
|
|
import { selectedWaypoint } from '$lib/components/toolbar/tools/waypoint/waypoint';
|
2025-02-02 11:17:22 +01:00
|
|
|
import { MapPin, Square } from 'lucide-static';
|
2026-10-11 11:18:36 +02:00
|
|
|
import { getSymbolKey, symbols } from '$lib/data/symbols';
|
2026-10-04 10:15:51 +02:00
|
|
|
import { engine, type FileState, type Selection } from '$lib/engine';
|
2026-10-11 11:18:36 +02:00
|
|
|
import { isCovered, hasSelectionWithin, type FileTreeNode } from '$lib/engine/selection-helpers';
|
|
|
|
|
import { isSegmentHidden, isWaypointHidden } from '$lib/engine/file-visibility';
|
|
|
|
|
import { settings } from '$lib/state/settings';
|
2025-10-17 23:54:45 +02:00
|
|
|
import { currentTool, Tool } from '$lib/components/toolbar/tools';
|
2026-10-07 19:38:21 +02:00
|
|
|
import { splitAtPoint } from '$lib/components/toolbar/tools/scissors/scissors';
|
2026-10-11 11:18:36 +02:00
|
|
|
import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
2026-01-30 21:01:24 +01:00
|
|
|
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
2024-04-25 13:48:31 +02:00
|
|
|
|
2025-11-19 22:43:19 +01:00
|
|
|
export function getSvgForSymbol(symbol?: string | undefined, layerColor?: string | undefined) {
|
2024-08-08 23:20:09 +02:00
|
|
|
let symbolSvg = symbol ? symbols[symbol]?.iconSvg : undefined;
|
|
|
|
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
2025-11-19 22:43:19 +01:00
|
|
|
${
|
|
|
|
|
layerColor
|
|
|
|
|
? Square.replace('width="24"', 'width="12"')
|
|
|
|
|
.replace('height="24"', 'height="12"')
|
|
|
|
|
.replace('stroke="currentColor"', 'stroke="SteelBlue"')
|
|
|
|
|
.replace('stroke-width="2"', 'stroke-width="1.5" x="9.6" y="0.4"')
|
|
|
|
|
.replace('fill="none"', `fill="${layerColor}"`)
|
|
|
|
|
: ''
|
|
|
|
|
}
|
2025-02-02 11:17:22 +01:00
|
|
|
${MapPin.replace('width="24"', '')
|
|
|
|
|
.replace('height="24"', '')
|
|
|
|
|
.replace('stroke="currentColor"', '')
|
|
|
|
|
.replace('path', `path fill="#3fb1ce" stroke="SteelBlue" stroke-width="1"`)
|
|
|
|
|
.replace(
|
|
|
|
|
'circle',
|
|
|
|
|
`circle fill="${symbolSvg ? 'none' : 'white'}" stroke="${symbolSvg ? 'none' : 'white'}" stroke-width="2"`
|
|
|
|
|
)}
|
|
|
|
|
${
|
|
|
|
|
symbolSvg
|
|
|
|
|
?.replace('width="24"', 'width="10"')
|
2024-08-09 23:50:47 +02:00
|
|
|
.replace('height="24"', 'height="10"')
|
|
|
|
|
.replace('stroke="currentColor"', 'stroke="white"')
|
2025-02-02 11:17:22 +01:00
|
|
|
.replace('stroke-width="2"', 'stroke-width="2.5" x="7" y="5"') ?? ''
|
|
|
|
|
}
|
2024-08-09 23:50:47 +02:00
|
|
|
</svg>`;
|
2024-08-08 23:20:09 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-17 23:54:45 +02:00
|
|
|
const { directionMarkers, treeFileView, defaultOpacity, defaultWidth } = settings;
|
2024-05-08 14:53:28 +02:00
|
|
|
|
2024-04-25 14:55:35 +02:00
|
|
|
export class GPXLayer {
|
2024-04-30 20:55:47 +02:00
|
|
|
fileId: string;
|
2026-10-04 10:15:51 +02:00
|
|
|
file: Readable<FileState>;
|
|
|
|
|
layerColor: string = '';
|
|
|
|
|
selectionState: Selection = { type: 'empty' };
|
2024-05-24 20:23:49 +02:00
|
|
|
selected: boolean = false;
|
2025-11-19 21:59:17 +01:00
|
|
|
currentWaypointData: GeoJSON.FeatureCollection | null = null;
|
|
|
|
|
draggedWaypointIndex: number | null = null;
|
2026-07-24 19:06:39 +02:00
|
|
|
draggingStartingPosition: Point = new Point(0, 0);
|
2024-05-08 14:53:28 +02:00
|
|
|
unsubscribe: Function[] = [];
|
2024-04-25 13:48:31 +02:00
|
|
|
|
2024-05-03 15:59:34 +02:00
|
|
|
updateBinded: () => void = this.update.bind(this);
|
2024-06-13 09:44:27 +02:00
|
|
|
layerOnMouseEnterBinded: (e: any) => void = this.layerOnMouseEnter.bind(this);
|
2024-06-10 20:03:57 +02:00
|
|
|
layerOnMouseLeaveBinded: () => void = this.layerOnMouseLeave.bind(this);
|
2024-10-08 15:49:14 +02:00
|
|
|
layerOnMouseMoveBinded: (e: any) => void = this.layerOnMouseMove.bind(this);
|
2026-01-30 21:01:24 +01:00
|
|
|
layerOnClickBinded: (e: MapLayerMouseEvent) => void = this.layerOnClick.bind(this);
|
|
|
|
|
layerOnContextMenuBinded: (e: MapLayerMouseEvent) => void = this.layerOnContextMenu.bind(this);
|
|
|
|
|
waypointLayerOnMouseEnterBinded: (e: MapLayerMouseEvent) => void =
|
2025-11-19 21:59:17 +01:00
|
|
|
this.waypointLayerOnMouseEnter.bind(this);
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseLeaveBinded: (e: MapLayerMouseEvent) => void =
|
2025-11-19 21:59:17 +01:00
|
|
|
this.waypointLayerOnMouseLeave.bind(this);
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnClickBinded: (e: MapLayerMouseEvent) => void =
|
2025-11-19 21:59:17 +01:00
|
|
|
this.waypointLayerOnClick.bind(this);
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseDownBinded: (e: MapLayerMouseEvent) => void =
|
2025-11-19 21:59:17 +01:00
|
|
|
this.waypointLayerOnMouseDown.bind(this);
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnTouchStartBinded: (e: MapLayerTouchEvent) => void =
|
2025-11-19 21:59:17 +01:00
|
|
|
this.waypointLayerOnTouchStart.bind(this);
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseMoveBinded: (e: MapLayerMouseEvent | MapLayerTouchEvent) => void =
|
2025-11-19 21:59:17 +01:00
|
|
|
this.waypointLayerOnMouseMove.bind(this);
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseUpBinded: (e: MapLayerMouseEvent | MapLayerTouchEvent) => void =
|
2025-11-19 21:59:17 +01:00
|
|
|
this.waypointLayerOnMouseUp.bind(this);
|
2024-04-25 16:41:06 +02:00
|
|
|
|
2026-10-04 10:15:51 +02:00
|
|
|
constructor(fileId: string, file: Readable<FileState>) {
|
2024-05-03 15:59:34 +02:00
|
|
|
this.fileId = fileId;
|
2024-05-08 21:31:54 +02:00
|
|
|
this.file = file;
|
2025-10-17 23:54:45 +02:00
|
|
|
this.unsubscribe.push(
|
|
|
|
|
map.subscribe(($map) => {
|
|
|
|
|
if ($map) {
|
2026-01-30 21:01:24 +01:00
|
|
|
$map.on('style.load', this.updateBinded);
|
2025-10-17 23:54:45 +02:00
|
|
|
this.update();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
2024-05-08 14:53:28 +02:00
|
|
|
this.unsubscribe.push(file.subscribe(this.updateBinded));
|
2025-02-02 11:17:22 +01:00
|
|
|
this.unsubscribe.push(
|
2026-10-04 10:15:51 +02:00
|
|
|
engine.selection.subscribe(($selection) => {
|
|
|
|
|
this.selectionState = $selection;
|
|
|
|
|
let newSelected = hasSelectionWithin($selection, this.fileNode());
|
2025-02-02 11:17:22 +01:00
|
|
|
if (this.selected || newSelected) {
|
|
|
|
|
this.selected = newSelected;
|
|
|
|
|
this.update();
|
|
|
|
|
}
|
|
|
|
|
if (newSelected) {
|
|
|
|
|
this.moveToFront();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
);
|
2024-05-23 11:21:57 +02:00
|
|
|
this.unsubscribe.push(directionMarkers.subscribe(this.updateBinded));
|
2024-04-25 13:48:31 +02:00
|
|
|
}
|
|
|
|
|
|
2026-10-04 10:15:51 +02:00
|
|
|
fileNode(): FileTreeNode {
|
|
|
|
|
return { type: 'file', fileId: this.fileId };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
segmentNode(properties: GeoJSON.GeoJsonProperties): FileTreeNode {
|
|
|
|
|
return {
|
|
|
|
|
type: 'segment',
|
|
|
|
|
fileId: this.fileId,
|
|
|
|
|
trackId: properties!.trackId,
|
|
|
|
|
segmentId: properties!.segmentId,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-03 15:59:34 +02:00
|
|
|
update() {
|
2025-10-17 23:54:45 +02:00
|
|
|
const _map = get(map);
|
2026-01-31 12:57:08 +01:00
|
|
|
const layerEventManager = map.layerEventManager;
|
2026-10-04 10:15:51 +02:00
|
|
|
const state = get(this.file);
|
|
|
|
|
if (!_map || !layerEventManager) {
|
2024-05-03 15:59:34 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-04 10:15:51 +02:00
|
|
|
if (this.layerColor !== state.color) {
|
|
|
|
|
this.layerColor = state.color;
|
2024-06-19 16:15:21 +02:00
|
|
|
}
|
|
|
|
|
|
2025-12-24 16:34:40 +01:00
|
|
|
this.loadIcons();
|
|
|
|
|
|
2024-05-04 23:50:27 +02:00
|
|
|
try {
|
2026-01-30 21:01:24 +01:00
|
|
|
let source = _map.getSource(this.fileId) as GeoJSONSource | undefined;
|
2024-05-08 21:31:54 +02:00
|
|
|
if (source) {
|
|
|
|
|
source.setData(this.getGeoJSON());
|
|
|
|
|
} else {
|
2025-10-17 23:54:45 +02:00
|
|
|
_map.addSource(this.fileId, {
|
2024-05-04 23:50:27 +02:00
|
|
|
type: 'geojson',
|
2025-02-02 11:17:22 +01:00
|
|
|
data: this.getGeoJSON(),
|
2024-05-04 23:50:27 +02:00
|
|
|
});
|
|
|
|
|
}
|
2024-04-25 13:48:31 +02:00
|
|
|
|
2025-10-17 23:54:45 +02:00
|
|
|
if (!_map.getLayer(this.fileId)) {
|
2026-01-30 21:30:37 +01:00
|
|
|
_map.addLayer(
|
|
|
|
|
{
|
|
|
|
|
id: this.fileId,
|
|
|
|
|
type: 'line',
|
|
|
|
|
source: this.fileId,
|
|
|
|
|
layout: {
|
|
|
|
|
'line-join': 'round',
|
|
|
|
|
'line-cap': 'round',
|
|
|
|
|
},
|
|
|
|
|
paint: {
|
|
|
|
|
'line-color': ['get', 'color'],
|
|
|
|
|
'line-width': ['get', 'width'],
|
|
|
|
|
'line-opacity': ['get', 'opacity'],
|
|
|
|
|
},
|
2024-05-04 23:50:27 +02:00
|
|
|
},
|
2026-01-30 21:30:37 +01:00
|
|
|
ANCHOR_LAYER_KEY.tracks
|
|
|
|
|
);
|
2024-04-25 13:48:31 +02:00
|
|
|
|
2026-01-31 12:57:08 +01:00
|
|
|
layerEventManager.on('click', this.fileId, this.layerOnClickBinded);
|
|
|
|
|
layerEventManager.on('contextmenu', this.fileId, this.layerOnContextMenuBinded);
|
|
|
|
|
layerEventManager.on('mouseenter', this.fileId, this.layerOnMouseEnterBinded);
|
|
|
|
|
layerEventManager.on('mouseleave', this.fileId, this.layerOnMouseLeaveBinded);
|
|
|
|
|
layerEventManager.on('mousemove', this.fileId, this.layerOnMouseMoveBinded);
|
2024-05-04 23:50:27 +02:00
|
|
|
}
|
2024-05-08 14:53:28 +02:00
|
|
|
|
2026-10-04 10:15:51 +02:00
|
|
|
const visibleSegmentIds = state.segments.features
|
|
|
|
|
.filter(
|
|
|
|
|
({ properties }) =>
|
|
|
|
|
!isSegmentHidden(state, properties.trackId, properties.segmentId)
|
|
|
|
|
)
|
|
|
|
|
.map(({ properties }) => properties.segmentId);
|
2026-02-01 15:57:18 +01:00
|
|
|
const segmentFilter: FilterSpecification = [
|
|
|
|
|
'in',
|
2026-10-04 10:15:51 +02:00
|
|
|
['get', 'segmentId'],
|
|
|
|
|
['literal', visibleSegmentIds],
|
2026-02-01 15:57:18 +01:00
|
|
|
];
|
2025-11-19 21:59:17 +01:00
|
|
|
|
2026-02-01 15:57:18 +01:00
|
|
|
_map.setFilter(this.fileId, segmentFilter, { validate: false });
|
2025-11-19 21:59:17 +01:00
|
|
|
|
2024-05-08 14:53:28 +02:00
|
|
|
if (get(directionMarkers)) {
|
2025-10-17 23:54:45 +02:00
|
|
|
if (!_map.getLayer(this.fileId + '-direction')) {
|
|
|
|
|
_map.addLayer(
|
2025-02-02 11:17:22 +01:00
|
|
|
{
|
|
|
|
|
id: this.fileId + '-direction',
|
|
|
|
|
type: 'symbol',
|
|
|
|
|
source: this.fileId,
|
|
|
|
|
layout: {
|
|
|
|
|
'text-field': '»',
|
2026-05-27 22:03:53 +02:00
|
|
|
'text-offset': [0, -0.1],
|
2025-02-02 11:17:22 +01:00
|
|
|
'text-keep-upright': false,
|
|
|
|
|
'text-max-angle': 361,
|
|
|
|
|
'text-allow-overlap': true,
|
2026-05-27 22:03:53 +02:00
|
|
|
'text-font': ['Noto Sans Bold'],
|
2025-02-02 11:17:22 +01:00
|
|
|
'symbol-placement': 'line',
|
|
|
|
|
'symbol-spacing': 20,
|
|
|
|
|
},
|
|
|
|
|
paint: {
|
|
|
|
|
'text-color': 'white',
|
|
|
|
|
'text-halo-width': 0.2,
|
|
|
|
|
'text-halo-color': 'white',
|
|
|
|
|
},
|
2024-05-08 14:53:28 +02:00
|
|
|
},
|
2026-01-30 21:30:37 +01:00
|
|
|
ANCHOR_LAYER_KEY.directionMarkers
|
2025-02-02 11:17:22 +01:00
|
|
|
);
|
2024-05-08 14:53:28 +02:00
|
|
|
}
|
2026-02-01 15:57:18 +01:00
|
|
|
|
|
|
|
|
_map.setFilter(this.fileId + '-direction', segmentFilter, { validate: false });
|
2024-05-08 14:53:28 +02:00
|
|
|
} else {
|
2025-10-17 23:54:45 +02:00
|
|
|
if (_map.getLayer(this.fileId + '-direction')) {
|
|
|
|
|
_map.removeLayer(this.fileId + '-direction');
|
2024-05-08 14:53:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-07-02 20:04:17 +02:00
|
|
|
|
2025-11-19 21:59:17 +01:00
|
|
|
let waypointSource = _map.getSource(this.fileId + '-waypoints') as
|
2026-01-30 21:01:24 +01:00
|
|
|
| GeoJSONSource
|
2025-11-19 21:59:17 +01:00
|
|
|
| undefined;
|
|
|
|
|
this.currentWaypointData = this.getWaypointsGeoJSON();
|
|
|
|
|
if (waypointSource) {
|
|
|
|
|
waypointSource.setData(this.currentWaypointData);
|
|
|
|
|
} else {
|
|
|
|
|
_map.addSource(this.fileId + '-waypoints', {
|
|
|
|
|
type: 'geojson',
|
|
|
|
|
data: this.currentWaypointData,
|
2026-02-14 14:35:35 +01:00
|
|
|
promoteId: 'waypointIndex',
|
2025-11-19 21:59:17 +01:00
|
|
|
});
|
|
|
|
|
}
|
2024-07-02 20:04:17 +02:00
|
|
|
|
2025-11-19 21:59:17 +01:00
|
|
|
if (!_map.getLayer(this.fileId + '-waypoints')) {
|
2026-01-30 21:01:24 +01:00
|
|
|
_map.addLayer(
|
|
|
|
|
{
|
|
|
|
|
id: this.fileId + '-waypoints',
|
|
|
|
|
type: 'symbol',
|
|
|
|
|
source: this.fileId + '-waypoints',
|
|
|
|
|
layout: {
|
|
|
|
|
'icon-image': ['get', 'icon'],
|
|
|
|
|
'icon-size': 0.3,
|
|
|
|
|
'icon-anchor': 'bottom',
|
|
|
|
|
'icon-padding': 0,
|
|
|
|
|
'icon-allow-overlap': true,
|
|
|
|
|
},
|
2025-11-19 21:59:17 +01:00
|
|
|
},
|
2026-01-30 21:01:24 +01:00
|
|
|
ANCHOR_LAYER_KEY.waypoints
|
|
|
|
|
);
|
2025-12-24 08:48:21 +01:00
|
|
|
|
2026-01-31 12:57:08 +01:00
|
|
|
layerEventManager.on(
|
2025-11-19 21:59:17 +01:00
|
|
|
'mouseenter',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnMouseEnterBinded
|
|
|
|
|
);
|
2026-01-31 12:57:08 +01:00
|
|
|
layerEventManager.on(
|
2025-11-19 21:59:17 +01:00
|
|
|
'mouseleave',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnMouseLeaveBinded
|
|
|
|
|
);
|
2026-01-31 12:57:08 +01:00
|
|
|
layerEventManager.on(
|
|
|
|
|
'click',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnClickBinded
|
|
|
|
|
);
|
|
|
|
|
layerEventManager.on(
|
2025-11-19 21:59:17 +01:00
|
|
|
'mousedown',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnMouseDownBinded
|
|
|
|
|
);
|
2026-01-31 12:57:08 +01:00
|
|
|
layerEventManager.on(
|
2025-11-19 23:45:28 +01:00
|
|
|
'touchstart',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnTouchStartBinded
|
|
|
|
|
);
|
2025-12-24 08:48:21 +01:00
|
|
|
}
|
2025-11-19 21:59:17 +01:00
|
|
|
|
2026-10-04 10:15:51 +02:00
|
|
|
const visibleWaypoints = state.waypoints.features
|
|
|
|
|
.filter(({ properties }) => !isWaypointHidden(state, properties.waypointId))
|
|
|
|
|
.map(({ properties }) => properties.index);
|
2025-11-19 21:59:17 +01:00
|
|
|
|
|
|
|
|
_map.setFilter(
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
['in', ['get', 'waypointIndex'], ['literal', visibleWaypoints]],
|
|
|
|
|
{ validate: false }
|
|
|
|
|
);
|
2025-02-02 11:17:22 +01:00
|
|
|
} catch (e) {
|
|
|
|
|
// No reliable way to check if the map is ready to add sources and layers
|
2024-05-04 23:50:27 +02:00
|
|
|
return;
|
2024-04-25 13:48:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-13 11:42:21 +02:00
|
|
|
remove() {
|
2025-10-17 23:54:45 +02:00
|
|
|
const _map = get(map);
|
2024-07-13 11:42:21 +02:00
|
|
|
|
2026-01-31 12:57:08 +01:00
|
|
|
if (_map) {
|
|
|
|
|
_map.off('style.load', this.updateBinded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const layerEventManager = map.layerEventManager;
|
|
|
|
|
if (layerEventManager) {
|
|
|
|
|
layerEventManager.off('click', this.fileId, this.layerOnClickBinded);
|
|
|
|
|
layerEventManager.off('contextmenu', this.fileId, this.layerOnContextMenuBinded);
|
|
|
|
|
layerEventManager.off('mouseenter', this.fileId, this.layerOnMouseEnterBinded);
|
|
|
|
|
layerEventManager.off('mouseleave', this.fileId, this.layerOnMouseLeaveBinded);
|
|
|
|
|
layerEventManager.off('mousemove', this.fileId, this.layerOnMouseMoveBinded);
|
|
|
|
|
|
|
|
|
|
layerEventManager.off(
|
2025-11-19 21:59:17 +01:00
|
|
|
'mouseenter',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnMouseEnterBinded
|
|
|
|
|
);
|
2026-01-31 12:57:08 +01:00
|
|
|
layerEventManager.off(
|
2025-11-19 21:59:17 +01:00
|
|
|
'mouseleave',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnMouseLeaveBinded
|
|
|
|
|
);
|
2026-01-31 12:57:08 +01:00
|
|
|
layerEventManager.off(
|
|
|
|
|
'click',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnClickBinded
|
|
|
|
|
);
|
|
|
|
|
layerEventManager.off(
|
|
|
|
|
'mousedown',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnMouseDownBinded
|
|
|
|
|
);
|
|
|
|
|
layerEventManager.off(
|
2025-11-20 00:25:56 +01:00
|
|
|
'touchstart',
|
|
|
|
|
this.fileId + '-waypoints',
|
|
|
|
|
this.waypointLayerOnTouchStartBinded
|
|
|
|
|
);
|
2026-01-31 12:57:08 +01:00
|
|
|
}
|
2025-11-19 21:59:17 +01:00
|
|
|
|
2026-01-31 12:57:08 +01:00
|
|
|
if (_map) {
|
2025-10-17 23:54:45 +02:00
|
|
|
if (_map.getLayer(this.fileId + '-direction')) {
|
|
|
|
|
_map.removeLayer(this.fileId + '-direction');
|
2024-07-13 11:42:21 +02:00
|
|
|
}
|
2025-10-17 23:54:45 +02:00
|
|
|
if (_map.getLayer(this.fileId)) {
|
|
|
|
|
_map.removeLayer(this.fileId);
|
2024-07-13 11:42:21 +02:00
|
|
|
}
|
2025-10-17 23:54:45 +02:00
|
|
|
if (_map.getSource(this.fileId)) {
|
|
|
|
|
_map.removeSource(this.fileId);
|
2024-07-13 11:42:21 +02:00
|
|
|
}
|
2025-11-19 21:59:17 +01:00
|
|
|
if (_map.getLayer(this.fileId + '-waypoints')) {
|
|
|
|
|
_map.removeLayer(this.fileId + '-waypoints');
|
|
|
|
|
}
|
|
|
|
|
if (_map.getSource(this.fileId + '-waypoints')) {
|
|
|
|
|
_map.removeSource(this.fileId + '-waypoints');
|
|
|
|
|
}
|
2024-05-04 23:50:27 +02:00
|
|
|
}
|
2024-04-25 13:48:31 +02:00
|
|
|
|
2024-05-08 14:53:28 +02:00
|
|
|
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
|
2024-04-25 13:48:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
moveToFront() {
|
2025-10-17 23:54:45 +02:00
|
|
|
const _map = get(map);
|
|
|
|
|
if (!_map) {
|
|
|
|
|
return;
|
2024-05-03 15:59:34 +02:00
|
|
|
}
|
2025-10-17 23:54:45 +02:00
|
|
|
if (_map.getLayer(this.fileId)) {
|
2026-01-30 21:30:37 +01:00
|
|
|
_map.moveLayer(this.fileId, ANCHOR_LAYER_KEY.tracks);
|
2025-10-17 23:54:45 +02:00
|
|
|
}
|
2025-11-19 21:59:17 +01:00
|
|
|
if (_map.getLayer(this.fileId + '-waypoints')) {
|
2026-01-30 21:30:37 +01:00
|
|
|
_map.moveLayer(this.fileId + '-waypoints', ANCHOR_LAYER_KEY.waypoints);
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
2025-10-17 23:54:45 +02:00
|
|
|
if (_map.getLayer(this.fileId + '-direction')) {
|
2026-01-30 21:30:37 +01:00
|
|
|
_map.moveLayer(this.fileId + '-direction', ANCHOR_LAYER_KEY.directionMarkers);
|
2024-05-08 14:53:28 +02:00
|
|
|
}
|
2024-04-25 13:48:31 +02:00
|
|
|
}
|
|
|
|
|
|
2024-06-10 20:03:57 +02:00
|
|
|
layerOnMouseEnter(e: any) {
|
2025-02-02 11:17:22 +01:00
|
|
|
if (
|
|
|
|
|
get(currentTool) === Tool.SCISSORS &&
|
2026-10-04 10:15:51 +02:00
|
|
|
isCovered(this.selectionState, this.segmentNode(e.features[0].properties))
|
2025-02-02 11:17:22 +01:00
|
|
|
) {
|
2025-10-18 16:10:08 +02:00
|
|
|
mapCursor.notify(MapCursorState.SCISSORS, true);
|
2024-06-10 20:03:57 +02:00
|
|
|
} else {
|
2025-10-18 16:10:08 +02:00
|
|
|
mapCursor.notify(MapCursorState.LAYER_HOVER, true);
|
2024-06-10 20:03:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layerOnMouseLeave() {
|
2025-10-18 16:10:08 +02:00
|
|
|
mapCursor.notify(MapCursorState.SCISSORS, false);
|
|
|
|
|
mapCursor.notify(MapCursorState.LAYER_HOVER, false);
|
2024-06-10 20:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2026-10-14 08:51:38 +02:00
|
|
|
async layerOnMouseMove(e: any) {
|
2025-06-04 18:41:28 +02:00
|
|
|
if (e.originalEvent.shiftKey) {
|
2026-10-04 17:09:41 +02:00
|
|
|
const { segmentId } = e.features[0].properties;
|
|
|
|
|
const lngLat = { lng: e.lngLat.lng, lat: e.lngLat.lat };
|
2026-10-14 08:51:38 +02:00
|
|
|
const index = closestPointIndex(await engine.segmentCoordinates(segmentId), lngLat);
|
2026-10-04 17:09:41 +02:00
|
|
|
const trackpoint =
|
2026-10-14 08:51:38 +02:00
|
|
|
index === undefined
|
|
|
|
|
? undefined
|
|
|
|
|
: await engine.trackpoint(this.fileId, segmentId, index);
|
2026-10-04 17:09:41 +02:00
|
|
|
if (trackpoint) {
|
|
|
|
|
trackpointPopup?.setItem({
|
|
|
|
|
item: trackpoint,
|
|
|
|
|
kind: 'trackpoint',
|
|
|
|
|
fileId: this.fileId,
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-10-08 15:49:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 21:01:24 +01:00
|
|
|
layerOnClick(e: MapLayerMouseEvent) {
|
2026-10-04 10:15:51 +02:00
|
|
|
const properties = e.features![0].properties!;
|
2026-10-07 19:38:21 +02:00
|
|
|
const { trackId, segmentId } = properties;
|
2026-10-04 10:15:51 +02:00
|
|
|
const selectionType = this.selectionState.type;
|
|
|
|
|
|
2025-02-02 11:17:22 +01:00
|
|
|
if (
|
|
|
|
|
get(currentTool) === Tool.ROUTING &&
|
2026-10-04 10:15:51 +02:00
|
|
|
selectionType !== 'empty' &&
|
|
|
|
|
selectionType !== 'waypoints' &&
|
|
|
|
|
selectionType !== 'waypoint'
|
2025-02-02 11:17:22 +01:00
|
|
|
) {
|
2024-04-25 13:56:07 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2024-05-24 13:16:41 +02:00
|
|
|
|
2025-02-02 11:17:22 +01:00
|
|
|
if (
|
|
|
|
|
get(currentTool) === Tool.SCISSORS &&
|
2026-10-04 10:15:51 +02:00
|
|
|
isCovered(this.selectionState, this.segmentNode(properties))
|
2025-02-02 11:17:22 +01:00
|
|
|
) {
|
2025-11-16 16:46:31 +01:00
|
|
|
if (get(map)?.queryRenderedFeatures(e.point, { layers: ['split-controls'] }).length) {
|
|
|
|
|
// Clicked on split control, ignoring
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-07 19:38:21 +02:00
|
|
|
splitAtPoint(segmentId, { lng: e.lngLat.lng, lat: e.lngLat.lat });
|
2024-06-10 20:03:57 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-04 10:29:39 +02:00
|
|
|
const mode = e.originalEvent.ctrlKey || e.originalEvent.metaKey ? 'add' : 'replace';
|
2026-10-04 10:15:51 +02:00
|
|
|
const { tracks } = get(this.file).structure;
|
|
|
|
|
const segmentCount = tracks.reduce((count, track) => count + track.segments.length, 0);
|
|
|
|
|
if (get(treeFileView) && segmentCount > 1) {
|
2025-02-02 11:17:22 +01:00
|
|
|
// Select inner item
|
2026-10-04 10:15:51 +02:00
|
|
|
const track = tracks.find((track) => track.id === trackId);
|
|
|
|
|
if (track && track.segments.length > 1) {
|
2026-10-04 10:29:39 +02:00
|
|
|
engine.selectSegments(this.fileId, trackId, [segmentId], mode);
|
2026-10-04 10:15:51 +02:00
|
|
|
} else {
|
2026-10-04 10:29:39 +02:00
|
|
|
engine.selectTracks(this.fileId, [trackId], mode);
|
2026-10-04 10:15:51 +02:00
|
|
|
}
|
2024-04-25 13:48:31 +02:00
|
|
|
} else {
|
2026-10-04 10:29:39 +02:00
|
|
|
engine.select([this.fileId], mode);
|
2024-04-25 13:48:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 10:13:03 +02:00
|
|
|
layerOnContextMenu(e: any) {
|
|
|
|
|
if (e.originalEvent.ctrlKey) {
|
|
|
|
|
this.layerOnClick(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseEnter(e: MapLayerMouseEvent) {
|
2025-11-19 21:59:17 +01:00
|
|
|
if (this.draggedWaypointIndex !== null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-04 17:09:41 +02:00
|
|
|
this.showWaypointPopup(e.features![0].properties!.waypointId);
|
2025-11-19 21:59:17 +01:00
|
|
|
|
|
|
|
|
mapCursor.notify(MapCursorState.WAYPOINT_HOVER, true);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-14 08:51:38 +02:00
|
|
|
async showWaypointPopup(waypointId: string) {
|
|
|
|
|
const waypoint = await engine.waypoint(this.fileId, waypointId);
|
2026-10-04 17:09:41 +02:00
|
|
|
if (waypoint) {
|
|
|
|
|
waypointPopup?.setItem({ item: waypoint, kind: 'waypoint', fileId: this.fileId });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-19 21:59:17 +01:00
|
|
|
waypointLayerOnMouseLeave() {
|
|
|
|
|
mapCursor.notify(MapCursorState.WAYPOINT_HOVER, false);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnClick(e: MapLayerMouseEvent) {
|
2025-11-19 21:59:17 +01:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
2026-10-04 17:09:41 +02:00
|
|
|
const { waypointId } = e.features![0].properties!;
|
2025-11-19 21:59:17 +01:00
|
|
|
if (get(currentTool) === Tool.WAYPOINT) {
|
|
|
|
|
if (this.selected) {
|
|
|
|
|
if (e.originalEvent.shiftKey) {
|
2026-10-04 17:09:41 +02:00
|
|
|
engine.deleteWaypoint(this.fileId, waypointId);
|
2025-11-19 21:59:17 +01:00
|
|
|
} else {
|
2026-10-04 10:15:51 +02:00
|
|
|
engine.selectWaypoints(this.fileId, [waypointId]);
|
2026-10-04 17:09:41 +02:00
|
|
|
selectedWaypoint.set({ fileId: this.fileId, id: waypointId });
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (get(treeFileView)) {
|
2026-10-04 10:15:51 +02:00
|
|
|
engine.selectWaypoints(this.fileId, [waypointId]);
|
2025-11-19 21:59:17 +01:00
|
|
|
} else {
|
2026-10-04 10:15:51 +02:00
|
|
|
engine.select([this.fileId]);
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
2026-10-04 17:09:41 +02:00
|
|
|
selectedWaypoint.set({ fileId: this.fileId, id: waypointId });
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (get(treeFileView)) {
|
2026-10-04 10:15:51 +02:00
|
|
|
const add = e.originalEvent.ctrlKey || e.originalEvent.metaKey;
|
2026-10-04 10:29:39 +02:00
|
|
|
engine.selectWaypoints(
|
|
|
|
|
this.fileId,
|
|
|
|
|
[waypointId],
|
|
|
|
|
add && this.selected ? 'add' : 'replace'
|
|
|
|
|
);
|
2025-11-19 21:59:17 +01:00
|
|
|
} else {
|
|
|
|
|
if (!this.selected) {
|
2026-10-04 10:15:51 +02:00
|
|
|
engine.select([this.fileId]);
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
2026-10-04 17:09:41 +02:00
|
|
|
this.showWaypointPopup(waypointId);
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseDown(e: MapLayerMouseEvent) {
|
2025-11-19 21:59:17 +01:00
|
|
|
if (get(currentTool) !== Tool.WAYPOINT || !this.selected) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const _map = get(map);
|
|
|
|
|
if (!_map) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
2026-01-31 12:57:08 +01:00
|
|
|
_map.dragPan.disable();
|
2025-11-19 21:59:17 +01:00
|
|
|
|
|
|
|
|
this.draggedWaypointIndex = e.features![0].properties!.waypointIndex;
|
2025-11-19 22:28:40 +01:00
|
|
|
this.draggingStartingPosition = e.point;
|
2025-11-19 21:59:17 +01:00
|
|
|
waypointPopup?.hide();
|
|
|
|
|
|
|
|
|
|
_map.on('mousemove', this.waypointLayerOnMouseMoveBinded);
|
|
|
|
|
_map.once('mouseup', this.waypointLayerOnMouseUpBinded);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnTouchStart(e: MapLayerTouchEvent) {
|
2025-11-19 23:45:28 +01:00
|
|
|
if (e.points.length !== 1 || get(currentTool) !== Tool.WAYPOINT || !this.selected) {
|
2025-11-19 21:59:17 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const _map = get(map);
|
|
|
|
|
if (!_map) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-19 23:45:28 +01:00
|
|
|
this.draggedWaypointIndex = e.features![0].properties!.waypointIndex;
|
2025-11-19 22:28:40 +01:00
|
|
|
this.draggingStartingPosition = e.point;
|
2025-11-19 21:59:17 +01:00
|
|
|
waypointPopup?.hide();
|
|
|
|
|
|
|
|
|
|
e.preventDefault();
|
2026-01-31 12:57:08 +01:00
|
|
|
_map.dragPan.disable();
|
2025-11-19 21:59:17 +01:00
|
|
|
|
|
|
|
|
_map.on('touchmove', this.waypointLayerOnMouseMoveBinded);
|
|
|
|
|
_map.once('touchend', this.waypointLayerOnMouseUpBinded);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseMove(e: MapLayerMouseEvent | MapLayerTouchEvent) {
|
2025-11-20 00:25:56 +01:00
|
|
|
if (this.draggedWaypointIndex === null || e.point.equals(this.draggingStartingPosition)) {
|
2025-11-19 21:59:17 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapCursor.notify(MapCursorState.WAYPOINT_DRAGGING, true);
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
this.currentWaypointData!.features[this.draggedWaypointIndex].geometry as GeoJSON.Point
|
|
|
|
|
).coordinates = [e.lngLat.lng, e.lngLat.lat];
|
|
|
|
|
|
|
|
|
|
let waypointSource = get(map)?.getSource(this.fileId + '-waypoints') as
|
2026-01-30 21:01:24 +01:00
|
|
|
| GeoJSONSource
|
2025-11-19 21:59:17 +01:00
|
|
|
| undefined;
|
|
|
|
|
if (waypointSource) {
|
2026-02-14 14:35:35 +01:00
|
|
|
waypointSource.updateData({
|
|
|
|
|
update: [
|
|
|
|
|
{
|
|
|
|
|
id: this.draggedWaypointIndex,
|
|
|
|
|
newGeometry: {
|
|
|
|
|
type: 'Point',
|
|
|
|
|
coordinates: [e.lngLat.lng, e.lngLat.lat],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
});
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 21:01:24 +01:00
|
|
|
waypointLayerOnMouseUp(e: MapLayerMouseEvent | MapLayerTouchEvent) {
|
2025-11-19 21:59:17 +01:00
|
|
|
mapCursor.notify(MapCursorState.WAYPOINT_DRAGGING, false);
|
|
|
|
|
|
2026-01-31 12:57:08 +01:00
|
|
|
const _map = get(map);
|
|
|
|
|
if (!_map) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_map.dragPan.enable();
|
|
|
|
|
|
|
|
|
|
_map.off('mousemove', this.waypointLayerOnMouseMoveBinded);
|
|
|
|
|
_map.off('touchmove', this.waypointLayerOnMouseMoveBinded);
|
2025-11-19 21:59:17 +01:00
|
|
|
|
|
|
|
|
if (this.draggedWaypointIndex === null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-11-19 22:28:40 +01:00
|
|
|
if (e.point.equals(this.draggingStartingPosition)) {
|
|
|
|
|
this.draggedWaypointIndex = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-11-19 21:59:17 +01:00
|
|
|
|
2026-10-04 17:09:41 +02:00
|
|
|
// the dragged waypoint, as it is in the features of the source
|
|
|
|
|
const waypointId =
|
|
|
|
|
this.currentWaypointData?.features[this.draggedWaypointIndex].properties?.waypointId;
|
2025-11-19 21:59:17 +01:00
|
|
|
getElevation([
|
|
|
|
|
{
|
|
|
|
|
lat: e.lngLat.lat,
|
2026-10-08 18:34:19 +02:00
|
|
|
lng: e.lngLat.lng,
|
2025-11-19 21:59:17 +01:00
|
|
|
},
|
2026-10-04 17:09:41 +02:00
|
|
|
]).then(async (ele) => {
|
2025-11-19 21:59:17 +01:00
|
|
|
if (this.draggedWaypointIndex === null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-10-04 17:09:41 +02:00
|
|
|
if (waypointId) {
|
|
|
|
|
await engine.moveWaypoint(
|
|
|
|
|
this.fileId,
|
|
|
|
|
waypointId,
|
|
|
|
|
e.lngLat.lng,
|
|
|
|
|
e.lngLat.lat,
|
|
|
|
|
ele[0]
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-11-19 21:59:17 +01:00
|
|
|
this.draggedWaypointIndex = null;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-25 13:48:31 +02:00
|
|
|
getGeoJSON(): GeoJSON.FeatureCollection {
|
2026-10-04 10:15:51 +02:00
|
|
|
const state = get(this.file);
|
|
|
|
|
const waypointsSelected = hasSelectionWithin(this.selectionState, {
|
|
|
|
|
type: 'waypoints',
|
|
|
|
|
fileId: this.fileId,
|
|
|
|
|
});
|
2024-05-03 15:59:34 +02:00
|
|
|
|
2026-10-04 10:15:51 +02:00
|
|
|
return {
|
|
|
|
|
type: 'FeatureCollection',
|
|
|
|
|
features: state.segments.features.map((feature) => {
|
|
|
|
|
const properties = {
|
|
|
|
|
...feature.properties,
|
|
|
|
|
opacity: feature.properties.opacity ?? get(defaultOpacity),
|
|
|
|
|
width: feature.properties.width ?? get(defaultWidth),
|
|
|
|
|
};
|
|
|
|
|
if (
|
|
|
|
|
isCovered(this.selectionState, this.segmentNode(properties)) ||
|
|
|
|
|
waypointsSelected
|
|
|
|
|
) {
|
|
|
|
|
properties.width = properties.width + 2;
|
|
|
|
|
properties.opacity = Math.min(1, properties.opacity + 0.1);
|
|
|
|
|
}
|
|
|
|
|
return { ...feature, properties };
|
|
|
|
|
}),
|
|
|
|
|
};
|
2024-05-08 21:31:54 +02:00
|
|
|
}
|
2025-11-19 21:59:17 +01:00
|
|
|
|
|
|
|
|
getWaypointsGeoJSON(): GeoJSON.FeatureCollection {
|
2026-10-04 10:15:51 +02:00
|
|
|
return {
|
2025-11-19 21:59:17 +01:00
|
|
|
type: 'FeatureCollection',
|
2026-10-04 10:15:51 +02:00
|
|
|
features: get(this.file).waypoints.features.map((feature) => ({
|
2025-11-19 21:59:17 +01:00
|
|
|
type: 'Feature',
|
2026-10-04 10:15:51 +02:00
|
|
|
// copied: the coordinates are changed while a waypoint is dragged
|
|
|
|
|
geometry: { type: 'Point', coordinates: [...feature.geometry.coordinates] },
|
2025-11-19 21:59:17 +01:00
|
|
|
properties: {
|
|
|
|
|
fileId: this.fileId,
|
2026-10-04 10:15:51 +02:00
|
|
|
waypointId: feature.properties.waypointId,
|
|
|
|
|
waypointIndex: feature.properties.index,
|
|
|
|
|
icon: `waypoint-${getSymbolKey(feature.properties.sym) ?? 'default'}-${this.layerColor}`,
|
2025-11-19 21:59:17 +01:00
|
|
|
},
|
2026-10-04 10:15:51 +02:00
|
|
|
})),
|
|
|
|
|
};
|
2025-11-19 21:59:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadIcons() {
|
|
|
|
|
const _map = get(map);
|
2026-10-04 10:15:51 +02:00
|
|
|
if (!_map) {
|
2025-11-19 21:59:17 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let symbols = new Set<string | undefined>();
|
2026-10-04 10:15:51 +02:00
|
|
|
get(this.file).waypoints.features.forEach((feature) => {
|
|
|
|
|
symbols.add(getSymbolKey(feature.properties.sym));
|
2025-11-19 21:59:17 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
symbols.forEach((symbol) => {
|
2025-12-24 16:34:40 +01:00
|
|
|
const iconId = `waypoint-${symbol ?? 'default'}-${this.layerColor}`;
|
2026-02-01 17:18:17 +01:00
|
|
|
loadSVGIcon(_map, iconId, getSvgForSymbol(symbol, this.layerColor));
|
2025-11-19 21:59:17 +01:00
|
|
|
});
|
|
|
|
|
}
|
2025-02-02 11:17:22 +01:00
|
|
|
}
|