diff --git a/website/package-lock.json b/website/package-lock.json index f5720e71..5be67fda 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -11,6 +11,8 @@ "@fortawesome/free-brands-svg-icons": "^6.5.2", "@fortawesome/free-solid-svg-icons": "^6.5.2", "@mapbox/mapbox-gl-geocoder": "^5.0.2", + "@types/mapbox__mapbox-gl-geocoder": "^5.0.0", + "@types/mapbox-gl": "^3.1.0", "bits-ui": "^0.21.2", "clsx": "^2.1.0", "gpx": "file:../gpx", @@ -1370,6 +1372,11 @@ "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", "dev": true }, + "node_modules/@types/geojson": { + "version": "7946.0.14", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.14.tgz", + "integrity": "sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==" + }, "node_modules/@types/http-cache-semantics": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", @@ -1389,6 +1396,23 @@ "@types/node": "*" } }, + "node_modules/@types/mapbox__mapbox-gl-geocoder": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/mapbox__mapbox-gl-geocoder/-/mapbox__mapbox-gl-geocoder-5.0.0.tgz", + "integrity": "sha512-eGBWdFiP2QgmwndPyhwK6eBeOfyB8vRscp2C6Acqasx5dH8FvTo/VgXWCrCKFR3zkWek/H4w4/CwmBFOs7OLBA==", + "dependencies": { + "@types/geojson": "*", + "@types/mapbox-gl": "*" + } + }, + "node_modules/@types/mapbox-gl": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@types/mapbox-gl/-/mapbox-gl-3.1.0.tgz", + "integrity": "sha512-hI6cQDjw1bkJw7MC/eHMqq5TWUamLwsujnUUeiIX2KDRjxRNSYMjnHz07+LATz9I9XIsKumOtUz4gRYnZOJ/FA==", + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.5.tgz", diff --git a/website/package.json b/website/package.json index 20256863..3a0eb575 100644 --- a/website/package.json +++ b/website/package.json @@ -40,6 +40,8 @@ "@fortawesome/free-brands-svg-icons": "^6.5.2", "@fortawesome/free-solid-svg-icons": "^6.5.2", "@mapbox/mapbox-gl-geocoder": "^5.0.2", + "@types/mapbox__mapbox-gl-geocoder": "^5.0.0", + "@types/mapbox-gl": "^3.1.0", "bits-ui": "^0.21.2", "clsx": "^2.1.0", "gpx": "file:../gpx", diff --git a/website/src/lib/assets/layers.ts b/website/src/lib/assets/layers.ts new file mode 100644 index 00000000..9bcf8730 --- /dev/null +++ b/website/src/lib/assets/layers.ts @@ -0,0 +1,85 @@ +import { type AnySourceData, type Style } from 'mapbox-gl'; + +export const basemaps: { [key: string]: string | Style; } = { + mapboxOutdoors: 'mapbox://styles/mapbox/outdoors-v12', + mapboxSatellite: 'mapbox://styles/mapbox/satellite-v9', + openStreetMap: { + version: 8, + sources: { + openStreetMap: { + type: 'raster', + tiles: ['https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', 'https://b.tile.openstreetmap.org/{z}/{x}/{y}.png', 'https://c.tile.openstreetmap.org/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: 'Map tiles by OpenStreetMap tile servers, under the tile usage policy. Data by OpenStreetMap' + } + }, + layers: [{ + id: 'openStreetMap', + type: 'raster', + source: 'openStreetMap', + }], + }, + openTopoMap: { + version: 8, + sources: { + openTopoMap: { + type: 'raster', + tiles: ['https://tile.opentopomap.org/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 17, + attribution: '© OpenTopoMap © OpenStreetMap' + } + }, + layers: [{ + id: 'openTopoMap', + type: 'raster', + source: 'openTopoMap', + }], + }, + openHikingMap: { + version: 8, + sources: { + openHikingMap: { + type: 'raster', + tiles: ['https://maps.refuges.info/hiking/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 18, + attribution: '© sly © OpenStreetMap' + } + }, + layers: [{ + id: 'openHikingMap', + type: 'raster', + source: 'openHikingMap', + }], + }, + cyclOSM: { + version: 8, + sources: { + cyclOSM: { + type: 'raster', + tiles: ['https://a.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', 'https://b.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', 'https://c.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 17, + attribution: '© CyclOSM © OpenStreetMap' + } + }, + layers: [{ + id: 'cyclOSM', + type: 'raster', + source: 'cyclOSM', + }], + }, + linz: 'https://basemaps.linz.govt.nz/v1/tiles/topographic/EPSG:3857/style/topographic.json?api=d01fbtg0ar23gctac5m0jgyy2ds' +}; + +export const overlays: { [key: string]: AnySourceData; } = { + cyclOSMlite: { + type: 'raster', + tiles: ['https://a.tile-cyclosm.openstreetmap.fr/cyclosm-lite/{z}/{x}/{y}.png', 'https://b.tile-cyclosm.openstreetmap.fr/cyclosm-lite/{z}/{x}/{y}.png', 'https://c.tile-cyclosm.openstreetmap.fr/cyclosm-lite/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 17, + attribution: '© CyclOSM © OpenStreetMap' + }, +}; \ No newline at end of file diff --git a/website/src/lib/components/LayerControl.svelte b/website/src/lib/components/LayerControl.svelte new file mode 100644 index 00000000..9913df60 --- /dev/null +++ b/website/src/lib/components/LayerControl.svelte @@ -0,0 +1,63 @@ + + + +
+ +
+ +
diff --git a/website/src/lib/components/Map.svelte b/website/src/lib/components/Map.svelte index a9e383af..767176a9 100644 --- a/website/src/lib/components/Map.svelte +++ b/website/src/lib/components/Map.svelte @@ -6,6 +6,7 @@ import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder'; import '@mapbox/mapbox-gl-geocoder/dist/mapbox-gl-geocoder.css'; + import LayerControl from './LayerControl.svelte'; mapboxgl.accessToken = 'pk.eyJ1IjoiZ3B4c3R1ZGlvIiwiYSI6ImNrdHVoM2pjNTBodmUycG1yZTNwcnJ3MzkifQ.YZnNs9s9oCQPzoXAWs_SLg'; @@ -17,7 +18,7 @@ onMount(() => { map = new mapboxgl.Map({ container: 'map', - style: 'mapbox://styles/mapbox/outdoors-v12', + style: { version: 8, sources: {}, layers: [] }, projection: 'mercator', hash: true, language: 'auto', @@ -57,10 +58,18 @@ }) ); }); + + onDestroy(() => { + if (map) { + map.remove(); + } + });
-
+
+ +