Skip to content

Commit 696dfc8

Browse files
Get caching working
1 parent 5dc05bb commit 696dfc8

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

src/components/MapFeatures.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
const toggleAllFeatures = (visible: boolean) => {
5959
if (!visible) $fragment.featureLayers = []
6060
else $fragment.featureLayers = featureLayers.map((l) => l.get('id'))
61+
62+
for (const feature of featureLayers) feature.setVisible(visible)
6163
}
6264
</script>
6365

src/components/SettingsView.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<div>
3737
<h4 class="mt-2 font-semibold text-base">Layers</h4>
3838
<div class="flex flex-col gap-2 my-1">
39-
{#each layerDefinitions.filter((l) => l.type === 'base') as layer}
39+
{#each layerDefinitions as layer}
4040
<Card>
4141
<h5 class="font-semibold">{layer.name}</h5>
4242
<div class="text-gray-500 italic">{layer.description}</div>

src/layers/layerDefinitions.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { pickRandom } from "../utils/random";
44
import RenderEvent from "ol/render/Event";
55

66
export interface BaseLayerDefinition {
7-
id: string;
87
name: string;
98
description: string;
109
defaultVisible?: boolean;
10+
defaultCache?: boolean;
1111
}
1212

1313
export type TileLayerDefinition = BaseLayerDefinition & {
@@ -25,7 +25,6 @@ export type LayerDefinition = BaseLayerDefinition
2525

2626
export const linzTopo: TileLayerDefinition =
2727
{
28-
id: 'linz-topo',
2928
name: "LINZ Topo",
3029
description: "The LINZ topographic map",
3130
type: "base",
@@ -38,21 +37,18 @@ export const linzTopo: TileLayerDefinition =
3837
export const layerDefinitions: TileLayerDefinition[] = [
3938
linzTopo,
4039
{
41-
id: 'osm',
4240
name: "Open Street Maps",
4341
description: "Street maps provided by openstreetmaps",
4442
type: 'base',
4543
url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
4644
},
4745
{
48-
id: 'open-topo-maps',
4946
name: "Open Topo Maps",
5047
description: "Topographic maps based on publicly available data",
5148
type: 'base',
5249
url: 'https://{a-c}.tile.opentopomap.org/{z}/{x}/{y}.png'
5350
},
5451
{
55-
id: 'linz-arial',
5652
name: 'LINZ Aerial Imagery',
5753
description: "High resolution imagery of New Zealand, provided by LINZ",
5854
type: 'base',
@@ -61,7 +57,6 @@ export const layerDefinitions: TileLayerDefinition[] = [
6157
}
6258
},
6359
{
64-
id: 'hillshade',
6560
name: "Hillshade",
6661
description: "Terrain relief overlay",
6762
type: 'overlay',

src/sources/cachingSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type CacheOptions = Omit<Options, "url"> & {
1111

1212
const getShouldCache = async (layer: { name: string }) => {
1313
const store = await getCurrentSettings();
14-
return store.layers?.[layer.name]?.cache ?? false;
14+
return store.layers?.[layer.name]?.cache ?? true
1515
}
1616

1717
export const getCacheId = (props: { name }, tile: TileCoord) => `${props.name}/${tile[2]}/${tile[0]}/${tile[1]}`;

0 commit comments

Comments
 (0)