From c6d435e3b553e0e53df1cb3a5b76b1a28b64253f Mon Sep 17 00:00:00 2001 From: vcoppe Date: Thu, 11 Apr 2024 17:51:48 +0200 Subject: [PATCH] all layers except strava --- website/src/lib/assets/layers.ts | 289 +++++++++++++++++- .../src/lib/components/LayerControl.svelte | 48 +-- 2 files changed, 316 insertions(+), 21 deletions(-) diff --git a/website/src/lib/assets/layers.ts b/website/src/lib/assets/layers.ts index 9bcf8730..597ef0b2 100644 --- a/website/src/lib/assets/layers.ts +++ b/website/src/lib/assets/layers.ts @@ -71,7 +71,211 @@ export const basemaps: { [key: string]: string | Style; } = { source: 'cyclOSM', }], }, - linz: 'https://basemaps.linz.govt.nz/v1/tiles/topographic/EPSG:3857/style/topographic.json?api=d01fbtg0ar23gctac5m0jgyy2ds' + linz: 'https://basemaps.linz.govt.nz/v1/tiles/topographic/EPSG:3857/style/topographic.json?api=d01fbtg0ar23gctac5m0jgyy2ds', + swisstopo: { + version: 8, + sources: { + swisstopo: { + type: 'raster', + tiles: ['https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/{z}/{x}/{y}.jpeg'], + tileSize: 256, + maxzoom: 18, + attribution: '© swisstopo' + } + }, + layers: [{ + id: 'swisstopo', + type: 'raster', + source: 'swisstopo', + }], + }, + linzTopo: { + version: 8, + sources: { + linzTopo: { + type: 'raster', + tiles: ['https://tiles-cdn.koordinates.com/services;key=39a8b989633a4bef98bc0e065380454a/tiles/v4/layer=50767/EPSG:3857/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© LINZ' + } + }, + layers: [{ + id: 'linzTopo', + type: 'raster', + source: 'linzTopo', + }], + }, + ignPlanV2: { + version: 8, + sources: { + ignPlanV2: { + type: 'raster', + tiles: ['https://data.geopf.fr/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}'], + tileSize: 256, + maxzoom: 18, + attribution: 'IGN-F/Géoportail' + } + }, + layers: [{ + id: 'ignPlanV2', + type: 'raster', + source: 'ignPlanV2', + }], + }, + ignFrScan25: { + version: 8, + sources: { + ignFrScan25: { + type: 'raster', + tiles: ['https://wxs.ign.fr/ifj1o8jmglxpfn6p1tn4b3g1/geoportail/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&TILEMATRIXSET=PM&TILEMATRIX={z}&TILECOL={x}&TILEROW={y}&LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN25TOUR&FORMAT=image/jpeg&STYLE=normal'], + tileSize: 256, + maxzoom: 16, + attribution: 'IGN-F/Géoportail' + } + }, + layers: [{ + id: 'ignFrScan25', + type: 'raster', + source: 'ignFrScan25', + }], + }, + ignSatellite: { + version: 8, + sources: { + ignSatellite: { + type: 'raster', + tiles: ['https://data.geopf.fr/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/jpeg&LAYER=ORTHOIMAGERY.ORTHOPHOTOS&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}'], + tileSize: 256, + maxzoom: 19, + attribution: 'IGN-F/Géoportail' + } + }, + layers: [{ + id: 'ignSatellite', + type: 'raster', + source: 'ignSatellite', + }], + }, + ignEs: { + version: 8, + sources: { + ignEs: { + type: 'raster', + tiles: ['https://www.ign.es/wmts/mapa-raster?layer=MTN&style=default&tilematrixset=GoogleMapsCompatible&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/jpeg&TileMatrix={z}&TileCol={x}&TileRow={y}'], + tileSize: 256, + maxzoom: 20, + attribution: 'IGN-F/Géoportail' + } + }, + layers: [{ + id: 'ignEs', + type: 'raster', + source: 'ignEs', + }], + }, + ordnanceSurvey: { + version: 8, + sources: { + ordnanceSurvey: { + type: 'raster', + tiles: ['https://api.os.uk/maps/raster/v1/zxy/Outdoor_3857/{z}/{x}/{y}.png?key=piCT8WysfuC3xLSUW7sGLfrAAJoYDvQz'], + tileSize: 256, + maxzoom: 20, + attribution: '© Ordnance Survey' + } + }, + layers: [{ + id: 'ordnanceSurvey', + type: 'raster', + source: 'ordnanceSurvey', + }], + }, + norwayTopo: { + version: 8, + sources: { + norwayTopo: { + type: 'raster', + tiles: ['https://opencache.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo4&zoom={z}&x={x}&y={y}', 'https://opencache2.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo4&zoom={z}&x={x}&y={y}', 'https://opencache3.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo4&zoom={z}&x={x}&y={y}'], + tileSize: 256, + maxzoom: 20, + attribution: '© Geonorge' + } + }, + layers: [{ + id: 'norwayTopo', + type: 'raster', + source: 'norwayTopo', + }], + }, + swedenTopo: { + version: 8, + sources: { + swedenTopo: { + type: 'raster', + tiles: ['https://api.lantmateriet.se/open/topowebb-ccby/v1/wmts/token/1d54dd14-a28c-38a9-b6f3-b4ebfcc3c204/1.0.0/topowebb/default/3857/{z}/{y}/{x}.png'], + tileSize: 256, + maxzoom: 14, + attribution: '© Lantmäteriet' + } + }, + layers: [{ + id: 'swedenTopo', + type: 'raster', + source: 'swedenTopo', + }], + }, + finlandTopo: { + version: 8, + sources: { + finlandTopo: { + type: 'raster', + tiles: ['https://avoin-karttakuva.maanmittauslaitos.fi/avoin/wmts?layer=maastokartta&style=default&tilematrixset=WGS84_Pseudo-Mercator&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix={z}&TileCol={x}&TileRow={y}&api-key=30cb768c-c968-493c-ae24-2b0b974ebd29'], + tileSize: 256, + maxzoom: 18, + attribution: '© Maanmittauslaitos' + } + }, + layers: [{ + id: 'finlandTopo', + type: 'raster', + source: 'finlandTopo', + }], + }, + bgMountains: { + version: 8, + sources: { + bgMountains: { + type: 'raster', + tiles: ['https://bgmtile.kade.si/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 19, + attribution: 'BGM Legend / CART Lab, BGM team, © CC BY-SA 4.0, Garmin version' + } + }, + layers: [{ + id: 'bgMountains', + type: 'raster', + source: 'bgMountains', + }], + }, + usgs: { + version: 8, + sources: { + usgs: { + type: 'raster', + tiles: ['https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}?blankTile=false'], + tileSize: 256, + maxzoom: 16, + attribution: '© USGS' + } + }, + layers: [{ + id: 'usgs', + type: 'raster', + source: 'usgs', + }], + }, }; export const overlays: { [key: string]: AnySourceData; } = { @@ -82,4 +286,87 @@ export const overlays: { [key: string]: AnySourceData; } = { maxzoom: 17, attribution: '© CyclOSM © OpenStreetMap' }, + swisstopoSlope: { + type: 'raster', + tiles: ['https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.hangneigung-ueber_30/default/current/3857/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 17, + attribution: '© swisstopo', + }, + swisstopoCycling: { + type: 'raster', + tiles: ['https://wmts.geo.admin.ch/1.0.0/ch.astra.veloland/default/current/3857/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© swisstopo' + }, + swisstopoMountainBike: { + type: 'raster', + tiles: ['https://wmts.geo.admin.ch/1.0.0/ch.astra.mountainbikeland/default/current/3857/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© swisstopo' + }, + ignFrCadastre: { + type: 'raster', + tiles: ['https://data.geopf.fr/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&TILEMATRIXSET=PM&TILEMATRIX={z}&TILECOL={x}&TILEROW={y}&LAYER=CADASTRALPARCELS.PARCELS&FORMAT=image/png&STYLE=normal'], + tileSize: 256, + maxzoom: 20, + attribution: 'IGN-F/Géoportail' + }, + ignSlope: { + type: 'raster', + tiles: ['https://data.geopf.fr/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&TileMatrixSet=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&Layer=GEOGRAPHICALGRIDSYSTEMS.SLOPES.MOUNTAIN&FORMAT=image/png&Style=normal'], + tileSize: 256, + maxzoom: 17, + attribution: 'IGN-F/Géoportail' + }, + waymarkedTrailsHiking: { + type: 'raster', + tiles: ['https://tile.waymarkedtrails.org/hiking/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© Waymarked Trails' + }, + waymarkedTrailsCycling: { + type: 'raster', + tiles: ['https://tile.waymarkedtrails.org/cycling/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© Waymarked Trails' + }, + waymarkedTrailsMTB: { + type: 'raster', + tiles: ['https://tile.waymarkedtrails.org/mtb/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© Waymarked Trails' + }, + waymarkedTrailsSkating: { + type: 'raster', + tiles: ['https://tile.waymarkedtrails.org/skating/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© Waymarked Trails' + }, + waymarkedTrailsHorseRiding: { + type: 'raster', + tiles: ['https://tile.waymarkedtrails.org/riding/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© Waymarked Trails' + }, + waymarkedTrailsWinter: { + type: 'raster', + tiles: ['https://tile.waymarkedtrails.org/slopes/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© Waymarked Trails' + }, +}; + +export const opacities: { [key: string]: number; } = { + ignFrCadastre: 0.5, + ignSlope: 0.4, + swisstopoSlope: 0.4, }; \ No newline at end of file diff --git a/website/src/lib/components/LayerControl.svelte b/website/src/lib/components/LayerControl.svelte index 9913df60..77ac3d26 100644 --- a/website/src/lib/components/LayerControl.svelte +++ b/website/src/lib/components/LayerControl.svelte @@ -9,7 +9,7 @@ import * as RadioGroup from '$lib/components/ui/radio-group'; import { Checkbox } from '$lib/components/ui/checkbox'; - import { basemaps, overlays } from '$lib/assets/layers'; + import { basemaps, overlays, opacities } from '$lib/assets/layers'; export let map: mapboxgl.Map | null; @@ -36,27 +36,35 @@ {/each} -
+
{#each Object.keys(overlays) as id} - { - console.log('onCheckedChange', map?.isStyleLoaded()); - if (checked) { - if (!map.getSource(id)) { - map.addSource(id, overlays[id]); +
+ { + if (checked) { + if (!map.getSource(id)) { + map.addSource(id, overlays[id]); + } + map.addLayer({ + id, + type: overlays[id].type === 'raster' ? 'raster' : 'line', + source: id, + paint: { + ...(id in opacities + ? overlays[id].type === 'raster' + ? { 'raster-opacity': opacities[id] } + : { 'line-opacity': opacities[id] } + : {}) + } + }); + } else { + map.removeLayer(id); } - map.addLayer({ - id, - type: overlays[id].type === 'raster' ? 'raster' : 'line', - source: id - }); - } else { - map.removeLayer(id); - } - }} - /> - + }} + /> + +
{/each}