Skip to content

Commit

Permalink
Add min zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
fallaciousreasoning committed Dec 19, 2023
1 parent 696dfc8 commit f203cf9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/TopoMap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
title={definition.name}
prerender={definition.prerender}
type={"overlay"}
minZoom={definition.minZoom}
visible={definition.defaultVisible}
source={cachingSource(definition)} />
{/each}
Expand Down
2 changes: 1 addition & 1 deletion src/components/MapFeatures.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<label>
<input
type="checkbox"
checked={$fragment.featureLayers.includes(layer.get('id'))}
checked={$fragment.featureLayers.includes(layer.get('id')) || layer.getVisible()}
on:change={(e) =>
setLayerVisible(layer, e.target['checked'])} />
{layer.get('title')}
Expand Down
3 changes: 2 additions & 1 deletion src/layers/layerDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface BaseLayerDefinition {
name: string;
description: string;
defaultVisible?: boolean;
defaultCache?: boolean;
minZoom?: number;
}

export type TileLayerDefinition = BaseLayerDefinition & {
Expand Down Expand Up @@ -62,6 +62,7 @@ export const layerDefinitions: TileLayerDefinition[] = [
type: 'overlay',
defaultVisible: true,
prerender: e => e.context.canvas.getContext('2d').globalCompositeOperation = 'multiply',
minZoom: 10,
url: 'https://tiles-cdn.koordinates.com/services;key=d0772bed2204423f87157f7fb1223389/tiles/v4/layer=50765/EPSG:3857/{z}/{x}/{y}.png'
}
]
2 changes: 2 additions & 0 deletions src/ol/TileLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
export let visible: boolean = true
export let opacity = 1
export let prerender: (e: RenderEvent) => void = undefined
export let minZoom: number | undefined = undefined
const { addLayer, removeLayer } = getOlContext()
const layer = new TileLayer({
['id' as any]: title,
['title' as any]: title,
['type' as any]: type,
['visible' as any]: visible,
minZoom,
opacity,
source: typeof source === 'string' ? new XYZ({ url: source }) : source,
})
Expand Down

1 comment on commit f203cf9

@vercel
Copy link

@vercel vercel bot commented on f203cf9 Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.