fix custom basemap tile URL update

This commit is contained in:
vcoppe
2024-08-14 09:21:55 +02:00
parent 069a598429
commit 22e9c76a5b
3 changed files with 14 additions and 4 deletions

View File

@@ -23,6 +23,7 @@
import { map } from '$lib/stores';
import { onDestroy, onMount } from 'svelte';
import Sortable from 'sortablejs/Sortable';
import { customBasemapUpdate } from './utils';
const {
customLayers,
@@ -130,6 +131,7 @@
[layerId]: {
type: 'raster',
tiles: tileUrls,
tileSize: 256,
maxzoom: maxZoom
}
},
@@ -145,6 +147,7 @@
layer.value = {
type: 'raster',
tiles: tileUrls,
tileSize: 256,
maxzoom: maxZoom
};
}
@@ -173,7 +176,11 @@
return $tree;
});
$currentBasemap = layerId;
if ($currentBasemap === layerId) {
$customBasemapUpdate++;
} else {
$currentBasemap = layerId;
}
if (!$customBasemapOrder.includes(layerId)) {
$customBasemapOrder = [...$customBasemapOrder, layerId];

View File

@@ -11,7 +11,7 @@
import { settings } from '$lib/db';
import { map } from '$lib/stores';
import { get, writable } from 'svelte/store';
import { getLayers } from './utils';
import { customBasemapUpdate, getLayers } from './utils';
import { OverpassLayer } from './OverpassLayer';
import OverpassPopup from './OverpassPopup.svelte';
@@ -41,7 +41,7 @@
}
}
$: if ($map && $currentBasemap) {
$: if ($map && ($currentBasemap || $customBasemapUpdate)) {
setStyle();
}

View File

@@ -1,4 +1,5 @@
import type { LayerTreeType } from "$lib/assets/layers";
import { writable } from "svelte/store";
export function anySelectedLayer(node: LayerTreeType) {
return Object.keys(node).find((id) => {
@@ -36,4 +37,6 @@ export function isSelected(node: LayerTreeType, id: string) {
}
return false;
});
}
}
export const customBasemapUpdate = writable(0);