From 75df460311bbed301a9a28bde7da59515cc34ffc Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Mon, 21 Jul 2025 19:57:31 +0200 Subject: [PATCH 1/6] Block out 3d buildings --- components/src/maplibre/Map/Map.svelte | 18 ++- .../src/maplibre/MapStyle/SWRDataLabLight.mdx | 3 +- .../MapStyle/SWRDataLabLight.stories.svelte | 25 +++- .../src/maplibre/MapStyle/SWRDataLabLight.ts | 127 +++++++++++------- .../maplibre/MapStyle/components/Buildings.ts | 44 +++--- components/src/maplibre/MapStyle/tokens.ts | 3 +- components/src/maplibre/types.ts | 12 +- 7 files changed, 161 insertions(+), 71 deletions(-) diff --git a/components/src/maplibre/Map/Map.svelte b/components/src/maplibre/Map/Map.svelte index a6c92c6c..c5b7557f 100644 --- a/components/src/maplibre/Map/Map.svelte +++ b/components/src/maplibre/Map/Map.svelte @@ -20,6 +20,7 @@ projection?: ProjectionSpecification; showDebug?: boolean; options?: any; + enableBuildingExtrusions?: boolean; children?: Snippet; } @@ -38,11 +39,22 @@ allowRotation = false, allowZoom = true, showDebug = false, - initialLocation = { lat: 51.3, lng: 10.2, zoom: 5 } + enableBuildingExtrusions = false, + initialLocation: receivedInitialLocation }: MapProps = $props(); let container: HTMLElement; + // Merge initial location with default object so individual + // properties (like pitch) can be omitted by the caller + let initialLocation = { + lat: 51.3, + lng: 10.2, + zoom: 5, + pitch: 0, + ...receivedInitialLocation + }; + const mapContext = createMapContext(); if (getContext('initialLocation') !== undefined && getContext('initialLocation') !== false) { initialLocation = getContext('initialLocation'); @@ -54,11 +66,11 @@ style, minZoom, maxZoom, - pitch, bearing, attributionControl: false, // Added via component center: [initialLocation.lng, initialLocation.lat], zoom: initialLocation.zoom, + pitch: initialLocation.pitch, ...options }); @@ -107,7 +119,7 @@ {/if} {#if showDebug}
-{Object.entries({ ...center, zoom, allowZoom, allowRotation })
+{Object.entries({ ...center, zoom, pitch, allowZoom, allowRotation })
 				.map(([key, val]) => `${key}: ${val}`)
 				.join('\n')}
{/if} diff --git a/components/src/maplibre/MapStyle/SWRDataLabLight.mdx b/components/src/maplibre/MapStyle/SWRDataLabLight.mdx index 5e50951a..0236ad73 100644 --- a/components/src/maplibre/MapStyle/SWRDataLabLight.mdx +++ b/components/src/maplibre/MapStyle/SWRDataLabLight.mdx @@ -12,8 +12,9 @@ Light-themed general-purpose basemap using SWR colours and typefaces based on - Data sources - Vector data: [versatiles-osm](https://download.versatiles.org/) in the [Shortbread schema](https://shortbread-tiles.org/) served from `tiles.versatiles.org` + - Building footprints with heights: [basemap-de](https://basemap.de/produkte-und-dienste/web-vektor/) vector tiles served from `sgx.geodatenzentrum.de` - Typefaces: SWR Sans served from `https://static.datenhub.net/maps/fonts/`. -- Layer count: {SWRDataLabLight.layers.length} +- Layer count: {SWRDataLabLight({enableBuildingExtrusions: true}).layers.length} (including building extrusions) diff --git a/components/src/maplibre/MapStyle/SWRDataLabLight.stories.svelte b/components/src/maplibre/MapStyle/SWRDataLabLight.stories.svelte index 60848f94..256b001e 100644 --- a/components/src/maplibre/MapStyle/SWRDataLabLight.stories.svelte +++ b/components/src/maplibre/MapStyle/SWRDataLabLight.stories.svelte @@ -17,7 +17,7 @@
@@ -27,6 +27,29 @@
+ + +
+
+ + + + +
+
+
+