From 95d241788359cb3422c270bb89dbc743ae90cda6 Mon Sep 17 00:00:00 2001 From: Jay Harris Date: Wed, 17 Apr 2024 17:28:05 +1200 Subject: [PATCH 1/3] Temp API key for basemaps --- src/layers/layerDefinitions.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/layers/layerDefinitions.ts b/src/layers/layerDefinitions.ts index ae16525..ec1df43 100644 --- a/src/layers/layerDefinitions.ts +++ b/src/layers/layerDefinitions.ts @@ -60,8 +60,7 @@ export const layerDefinitions: TileLayerDefinition[] = [ description: "Terrain relief overlay", 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' - } + url: 'https://basemaps.linz.govt.nz/v1/tiles/geographx-nz-dem-2012-8m/WebMercatorQuad/{z}/{x}/{y}.webp?api=c01hvn7wv0004d4njsf6rwk1t7p', + }, ] From 216b913fc17b25bd6bcb215fea34088a7a8d3134 Mon Sep 17 00:00:00 2001 From: Jay Harris Date: Wed, 17 Apr 2024 17:34:27 +1200 Subject: [PATCH 2/3] Add longpress --- src/components/MapPin.svelte | 14 +++++++++++++- src/layers/layerDefinitions.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/MapPin.svelte b/src/components/MapPin.svelte index 4a927f5..348db32 100644 --- a/src/components/MapPin.svelte +++ b/src/components/MapPin.svelte @@ -7,7 +7,19 @@ const { map } = getOlContext() - map.on('click', async (e) => { + const LONG_PRESS_THRESHOLD = 500; + + let mouseDownAt: number; + map.getTargetElement().addEventListener('mousedown', e => { + mouseDownAt = Date.now(); + }); + + map.on('singleclick', async (e) => { + const pressDuration = Date.now() - mouseDownAt + if (pressDuration < LONG_PRESS_THRESHOLD) { + return + } + const [lng, lat] = toLonLat(e.coordinate) const closestPoint = await findPlace(lat, lng) $fragment.label = { diff --git a/src/layers/layerDefinitions.ts b/src/layers/layerDefinitions.ts index ec1df43..35133bb 100644 --- a/src/layers/layerDefinitions.ts +++ b/src/layers/layerDefinitions.ts @@ -56,7 +56,7 @@ export const layerDefinitions: TileLayerDefinition[] = [ } }, { - name: "Hillshade", + name: "Hill shade", description: "Terrain relief overlay", type: 'overlay', defaultVisible: true, From 115f36c993ea5b0519371534550578cc3bd529a6 Mon Sep 17 00:00:00 2001 From: Jay Harris Date: Mon, 22 Apr 2024 14:36:42 +1200 Subject: [PATCH 3/3] Add better key --- src/layers/layerDefinitions.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/layers/layerDefinitions.ts b/src/layers/layerDefinitions.ts index 35133bb..3880427 100644 --- a/src/layers/layerDefinitions.ts +++ b/src/layers/layerDefinitions.ts @@ -33,6 +33,7 @@ export const linzTopo: TileLayerDefinition = }, }; +const LINZ_BASEMAPS = 'd01fbtg0ar3v159zx4e0ajt0n09' export const layerDefinitions: TileLayerDefinition[] = [ linzTopo, { @@ -52,7 +53,7 @@ export const layerDefinitions: TileLayerDefinition[] = [ description: "High resolution imagery of New Zealand, provided by LINZ", type: 'base', url: ([z,x,y]: TileCoord) => { - return `https://basemaps.linz.govt.nz/v1/tiles/aerial/EPSG:3857/${z}/${x}/${y}.webp?api=d01fbtg0ar3v159zx4e0ajt0n09`; + return `https://basemaps.linz.govt.nz/v1/tiles/aerial/EPSG:3857/${z}/${x}/${y}.webp?api=${LINZ_BASEMAPS}`; } }, { @@ -61,6 +62,6 @@ export const layerDefinitions: TileLayerDefinition[] = [ type: 'overlay', defaultVisible: true, minZoom: 10, - url: 'https://basemaps.linz.govt.nz/v1/tiles/geographx-nz-dem-2012-8m/WebMercatorQuad/{z}/{x}/{y}.webp?api=c01hvn7wv0004d4njsf6rwk1t7p', + url: `https://basemaps.linz.govt.nz/v1/tiles/geographx-nz-dem-2012-8m/WebMercatorQuad/{z}/{x}/{y}.webp?api=${LINZ_BASEMAPS}`, }, ]