From 3b533969ea8b974c9141c93f6f034f3498e00afe Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Fri, 12 Sep 2025 10:30:08 +0200 Subject: [PATCH] Add cursor prop, extend docs --- components/src/maplibre/Map/Map.svelte | 13 +++++++++- .../VectorLayer/VectorLayer.stories.svelte | 26 ++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/components/src/maplibre/Map/Map.svelte b/components/src/maplibre/Map/Map.svelte index 1813c920..ea5779ef 100644 --- a/components/src/maplibre/Map/Map.svelte +++ b/components/src/maplibre/Map/Map.svelte @@ -25,9 +25,13 @@ projection?: ProjectionSpecification; showDebug?: boolean; options?: any; + /** + * Set the mouse cursor. `""` (empty string) restores Maplibre's default behaviour. See VectorLayer/Default for a common usage example + */ + cursor?: string; mapContext?: MapContext; /** - * "Use Ctrl + scroll to zoom" + * Show "Use Ctrl + scroll to zoom" overlay */ cooperativeGestures?: boolean; onmovestart?: (e: MapLibreEvent) => null; @@ -50,6 +54,7 @@ allowRotation = false, allowZoom = true, showDebug = false, + cursor, initialLocation: receivedInitialLocation, // Future: This should become bindable.readonly when that becomes // available, see: https://github.com/sveltejs/svelte/issues/7712 @@ -122,6 +127,12 @@ if (mapContext.map) mapContext.map.setStyle(style); }); + $effect(() => { + if (mapContext.map) { + mapContext.map.getCanvas().style.cursor = cursor ?? ''; + } + }); + $effect(() => { if (mapContext.styleLoaded) { mapContext.map?.setProjection(projection); diff --git a/components/src/maplibre/VectorLayer/VectorLayer.stories.svelte b/components/src/maplibre/VectorLayer/VectorLayer.stories.svelte index 29445b55..cb40ea4f 100644 --- a/components/src/maplibre/VectorLayer/VectorLayer.stories.svelte +++ b/components/src/maplibre/VectorLayer/VectorLayer.stories.svelte @@ -1,4 +1,4 @@ -
- +