9 Commits

Author SHA1 Message Date
vcoppe
72578b00bd New translations map-controls.mdx (Spanish) 2026-04-17 12:36:31 +02:00
vcoppe
4ef49632f7 New translations integration.mdx (Spanish) 2026-04-17 12:36:30 +02:00
vcoppe
e3d45ebde7 New translations merge.mdx (Spanish) 2026-04-17 11:24:55 +02:00
vcoppe
d96fadf261 New translations integration.mdx (Spanish) 2026-04-17 11:24:54 +02:00
vcoppe
8dc20cbec7 New translations en.json (Spanish) 2026-04-17 11:24:53 +02:00
vcoppe
a3853c724f New translations en.json (Chinese Traditional, Hong Kong) 2026-04-17 05:11:14 +02:00
vcoppe
8ceaf2c8bd New translations elevation.mdx (Spanish) 2026-04-12 13:21:16 +02:00
vcoppe
1de15f702a New translations merge.mdx (Spanish) 2026-04-12 13:21:15 +02:00
vcoppe
0d1f1e9b23 New translations en.json (Spanish) 2026-04-12 13:21:14 +02:00
4 changed files with 61 additions and 98 deletions

View File

@@ -142,7 +142,6 @@ export class MapLayerEventManager {
}
private _handleMouseMove(e: maplibregl.MapMouseEvent) {
if (e.originalEvent.buttons > 0) return;
const featuresByLayer = this._getRenderedFeaturesByLayer(e);
Object.keys(this._listeners).forEach((layerId) => {
const features = featuresByLayer[layerId] || [];

View File

@@ -81,13 +81,8 @@ export class StyleManager {
let basemap = get(currentBasemap);
const basemapInfo = basemaps[basemap] ?? custom[basemap]?.value ?? basemaps[defaultBasemap];
const basemapStyle = await this.get(basemapInfo);
let basemapStyle = basemaps.openStreetMap as maplibregl.StyleSpecification;
try {
basemapStyle = await this.get(basemapInfo);
} catch (e) {
console.error(e.message);
}
this.merge(style, basemapStyle);
if (this._maptilerKey !== '') {
@@ -114,21 +109,16 @@ export class StyleManager {
if (!layers[overlay]) {
if (this._pastOverlays.has(overlay)) {
const overlayInfo = custom[overlay]?.value ?? overlays[overlay];
try {
const overlayStyle = await this.get(overlayInfo);
for (let layer of overlayStyle.layers ?? []) {
if (map_.getLayer(layer.id)) {
map_.removeLayer(layer.id);
}
}
} catch (e) {
// Should not happen
}
this._pastOverlays.delete(overlay);
}
} else {
const overlayInfo = custom[overlay]?.value ?? overlays[overlay];
try {
const overlayStyle = await this.get(overlayInfo);
const opacity = overlayOpacities[overlay];
@@ -156,10 +146,8 @@ export class StyleManager {
map_.addLayer(layer, ANCHOR_LAYER_KEY.overlays);
}
}
this._pastOverlays.add(overlay);
} catch (e) {
console.error(e.message);
}
}
}
} catch (e) {}
@@ -193,9 +181,6 @@ export class StyleManager {
styleUrl = styleUrl.replace(maptilerKeyPlaceHolder, this._maptilerKey);
}
const response = await fetch(styleUrl, { cache: 'force-cache' });
if (!response.ok) {
throw new Error(`HTTP error fetching style "${styleInfo}": ${response.status}`);
}
const style = await response.json();
return style;
} else {

View File

@@ -57,10 +57,8 @@ export class RoutingControls {
updateControlsBinded: () => void = this.updateControls.bind(this);
appendAnchorBinded: (e: MapMouseEvent) => void = this.appendAnchor.bind(this);
addIntermediateAnchorBinded: (e: MapMouseEvent) => void = this.addIntermediateAnchor.bind(this);
draggedAnchorIndex: number | null = null;
lastDraggedAnchorEventTime: number = 0;
draggingStartingPosition: maplibregl.Point = new maplibregl.Point(0, 0);
onMouseEnterBinded: () => void = this.onMouseEnter.bind(this);
onMouseLeaveBinded: () => void = this.onMouseLeave.bind(this);
@@ -135,7 +133,6 @@ export class RoutingControls {
map_.on('style.load', this.updateControlsBinded);
map_.on('click', this.appendAnchorBinded);
layerEventManager.on('mousemove', this.fileId, this.showTemporaryAnchorBinded);
layerEventManager.on('click', this.fileId, this.addIntermediateAnchorBinded);
this.fileUnsubscribe = this.file.subscribe(this.updateControlsBinded);
}
@@ -240,7 +237,6 @@ export class RoutingControls {
map_?.off('style.load', this.updateControlsBinded);
map_?.off('click', this.appendAnchorBinded);
layerEventManager?.off('mousemove', this.fileId, this.showTemporaryAnchorBinded);
layerEventManager?.off('click', this.fileId, this.addIntermediateAnchorBinded);
map_?.off('mousemove', this.updateTemporaryAnchorBinded);
this.layers.forEach((layer) => {
@@ -525,19 +521,12 @@ export class RoutingControls {
if (get(streetViewEnabled) && get(streetViewSource) === 'google') {
return;
}
if (
this.draggedAnchorIndex !== null ||
Date.now() - this.lastDraggedAnchorEventTime < 100
) {
// Exit if anchor is being dragged
return;
}
if (
e.target.queryRenderedFeatures(e.point, {
layers: [this.fileId, ...[...this.layers.values()].map((layer) => layer.id)],
layers: [...this.layers.values()].map((layer) => layer.id),
}).length
) {
// Clicked on routing control or layer, ignoring
// Clicked on routing control, ignoring
return;
}
this.appendAnchorWithCoordinates({
@@ -609,15 +598,6 @@ export class RoutingControls {
await this.routeBetweenAnchors([lastAnchor, newAnchor], [lastAnchorPoint, newAnchorPoint]);
}
addIntermediateAnchor(e: maplibregl.MapMouseEvent) {
e.preventDefault();
if (this.temporaryAnchor !== null) {
this.turnIntoPermanentAnchor();
return;
}
}
getNeighbouringAnchors(anchor: Anchor): [Anchor | null, Anchor | null] {
let previousAnchor: Anchor | null = null;
let nextAnchor: Anchor | null = null;
@@ -838,11 +818,8 @@ export class RoutingControls {
onClick(e: MapLayerMouseEvent) {
e.preventDefault();
if (
this.draggedAnchorIndex !== null ||
Date.now() - this.lastDraggedAnchorEventTime < 100
) {
// Exit if anchor is being dragged
if (this.temporaryAnchor !== null) {
this.turnIntoPermanentAnchor();
return;
}
@@ -931,8 +908,6 @@ export class RoutingControls {
lat: e.lngLat.lat,
lon: e.lngLat.lng,
});
this.lastDraggedAnchorEventTime = Date.now();
}
onMouseUp(e: MapLayerMouseEvent | MapLayerTouchEvent) {
@@ -971,7 +946,6 @@ export class RoutingControls {
}
this.draggedAnchorIndex = null;
this.lastDraggedAnchorEventTime = Date.now();
}
showTemporaryAnchor(e: MapLayerMouseEvent) {

View File

@@ -162,33 +162,38 @@ function getLayerValidator(allowed: Record<string, any>, fallback: string) {
function filterLayerTree(t: LayerTreeType, allowed: LayerTreeType | undefined): LayerTreeType {
const filtered: LayerTreeType = {};
const values = Object.values(t);
if (values.length == 0) return filtered;
if (typeof values[0] === 'boolean') {
if (allowed) {
Object.entries(allowed).forEach(([key, value]) => {
Object.keys(allowed).forEach((key) => {
if (Object.hasOwn(t, key)) {
if (typeof value === 'boolean') {
filtered[key] = t[key];
} else if (typeof value === 'object') {
filtered[key] = filterLayerTree(
typeof t[key] === 'object' ? t[key] : {},
value
);
}
} else {
filtered[key] = value;
filtered[key] = allowed[key];
}
});
}
Object.entries(t).forEach(([key, value]) => {
if (!Object.hasOwn(filtered, key)) {
if (typeof value === 'boolean') {
if (key.startsWith('custom-') || key.startsWith('extension-')) {
if (
!Object.hasOwn(filtered, key) &&
(key.startsWith('custom-') || key.startsWith('extension-'))
) {
filtered[key] = value;
}
} else if (typeof value === 'object') {
filtered[key] = filterLayerTree(value, undefined);
}
});
} else {
Object.entries(t).forEach(([key, value]) => {
if (typeof value === 'object') {
filtered[key] = filterLayerTree(
value,
typeof allowed === 'object' && typeof allowed[key] === 'object'
? allowed[key]
: undefined
);
}
});
}
return filtered;
}