From 0540c919e0682b418ce770d6481856fa909c11f8 Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Sun, 12 Oct 2025 14:39:13 +0200 Subject: [PATCH 1/3] Block out feature --- components/package.json | 1 + components/src/index.js | 2 + .../src/maplibre/ArrowSource/ArrowSource.mdx | 10 ++ .../ArrowSource/ArrowSource.stories.svelte | 97 ++++++++++++ .../maplibre/ArrowSource/ArrowSource.svelte | 138 ++++++++++++++++++ components/src/maplibre/ArrowSource/index.js | 2 + package-lock.json | 7 + 7 files changed, 257 insertions(+) create mode 100644 components/src/maplibre/ArrowSource/ArrowSource.mdx create mode 100644 components/src/maplibre/ArrowSource/ArrowSource.stories.svelte create mode 100644 components/src/maplibre/ArrowSource/ArrowSource.svelte create mode 100644 components/src/maplibre/ArrowSource/index.js diff --git a/components/package.json b/components/package.json index e517735a..84331440 100644 --- a/components/package.json +++ b/components/package.json @@ -33,6 +33,7 @@ "dependencies": { "@maplibre/maplibre-gl-geocoder": "^1.9.1", "@maplibre/maplibre-gl-inspect": "^1.7.1", + "bitmap-sdf": "^1.0.4", "maplibre-gl": "^5.7.0", "svelte-select": "^5.8.3" }, diff --git a/components/src/index.js b/components/src/index.js index 347844e9..140128dd 100644 --- a/components/src/index.js +++ b/components/src/index.js @@ -29,6 +29,8 @@ export { default as ScaleControl } from './maplibre/ScaleControl/ScaleControl.sv export { default as VectorLayer } from './maplibre/VectorLayer/VectorLayer.svelte'; export { default as VectorTileSource } from './maplibre/VectorTileSource/VectorTileSource.svelte'; export { default as GeoJSONSource } from './maplibre/GeoJSONSource/GeoJSONSource.svelte'; +export { default as ArrowSource } from './maplibre/ArrowSource/ArrowSource.svelte'; +export { default as MapSource } from './maplibre/Source/MapSource.svelte'; export { default as Tooltip } from './maplibre/Tooltip/Tooltip.svelte'; export { default as WithLinkLocation } from './maplibre/WithLinkLocation/WithLinkLocation.svelte'; diff --git a/components/src/maplibre/ArrowSource/ArrowSource.mdx b/components/src/maplibre/ArrowSource/ArrowSource.mdx new file mode 100644 index 00000000..48861ac9 --- /dev/null +++ b/components/src/maplibre/ArrowSource/ArrowSource.mdx @@ -0,0 +1,10 @@ +import { Story, Meta, Primary, Controls, Stories } from '@storybook/addon-docs/blocks'; + +import * as ArrowSourceStories from './ArrowSource.stories.svelte'; + + + +# ArrowSource + + + diff --git a/components/src/maplibre/ArrowSource/ArrowSource.stories.svelte b/components/src/maplibre/ArrowSource/ArrowSource.stories.svelte new file mode 100644 index 00000000..ec4f23e8 --- /dev/null +++ b/components/src/maplibre/ArrowSource/ArrowSource.stories.svelte @@ -0,0 +1,97 @@ + + + + +
+ + + + + + + +
+
+
+ + diff --git a/components/src/maplibre/ArrowSource/ArrowSource.svelte b/components/src/maplibre/ArrowSource/ArrowSource.svelte new file mode 100644 index 00000000..252fbebd --- /dev/null +++ b/components/src/maplibre/ArrowSource/ArrowSource.svelte @@ -0,0 +1,138 @@ + + + diff --git a/components/src/maplibre/ArrowSource/index.js b/components/src/maplibre/ArrowSource/index.js new file mode 100644 index 00000000..cadb874e --- /dev/null +++ b/components/src/maplibre/ArrowSource/index.js @@ -0,0 +1,2 @@ +import ArrowSource from './ArrowSource.svelte'; +export default ArrowSource; diff --git a/package-lock.json b/package-lock.json index 1ff684bb..bff0924b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "dependencies": { "@maplibre/maplibre-gl-geocoder": "^1.9.1", "@maplibre/maplibre-gl-inspect": "^1.7.1", + "bitmap-sdf": "^1.0.4", "maplibre-gl": "^5.7.0", "svelte-select": "^5.8.3" }, @@ -6537,6 +6538,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/bitmap-sdf": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bitmap-sdf/-/bitmap-sdf-1.0.4.tgz", + "integrity": "sha512-1G3U4n5JE6RAiALMxu0p1XmeZkTeCwGKykzsLTCqVzfSDaN6S7fKnkIkfejogz+iwqBWc0UYAIKnKHNN7pSfDg==", + "license": "MIT" + }, "node_modules/bottleneck": { "version": "2.19.5", "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", From 90d611c2e8dcfb21bc6b11ddcdf708720a49871f Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Sun, 12 Oct 2025 16:46:06 +0200 Subject: [PATCH 2/3] Iterate --- .../src/maplibre/ArrowSource/ArrowSource.mdx | 3 ++ .../maplibre/ArrowSource/ArrowSource.svelte | 39 +++++++++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/components/src/maplibre/ArrowSource/ArrowSource.mdx b/components/src/maplibre/ArrowSource/ArrowSource.mdx index 48861ac9..62fa8492 100644 --- a/components/src/maplibre/ArrowSource/ArrowSource.mdx +++ b/components/src/maplibre/ArrowSource/ArrowSource.mdx @@ -8,3 +8,6 @@ import * as ArrowSourceStories from './ArrowSource.stories.svelte'; +## Notes +- https://github.com/dy/bitmap-sdf +- https://github.com/maplibre/maplibre-gl-js/issues/5037 diff --git a/components/src/maplibre/ArrowSource/ArrowSource.svelte b/components/src/maplibre/ArrowSource/ArrowSource.svelte index 252fbebd..662a51e5 100644 --- a/components/src/maplibre/ArrowSource/ArrowSource.svelte +++ b/components/src/maplibre/ArrowSource/ArrowSource.svelte @@ -1,10 +1,11 @@ From 27104b2e329cebdde1b7d6c6f7f7c1ffdd88c66c Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Sun, 12 Oct 2025 17:06:14 +0200 Subject: [PATCH 3/3] Iterate docs --- .../src/maplibre/ArrowSource/ArrowSource.mdx | 57 ++++++++++++++++++- .../maplibre/ArrowSource/ArrowSource.svelte | 7 +-- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/components/src/maplibre/ArrowSource/ArrowSource.mdx b/components/src/maplibre/ArrowSource/ArrowSource.mdx index 62fa8492..a755dbe8 100644 --- a/components/src/maplibre/ArrowSource/ArrowSource.mdx +++ b/components/src/maplibre/ArrowSource/ArrowSource.mdx @@ -6,8 +6,61 @@ import * as ArrowSourceStories from './ArrowSource.stories.svelte'; # ArrowSource +Source component for creating smooth ([quadratic bezier](https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Quadratic_B%C3%A9zier_curves)) vector arrows [like these](https://www.nytimes.com/interactive/2025/10/09/world/americas/drug-trafficking-venezuela.html?searchResultPosition=4). + +## Usage + +ArrowSource takes an `arrow` prop of shape `ArrowSpec[]`: + +```js +interface ArrowSpec { + a: [number, number]; // Start point + b: [number, number]; // End point + c: [number, number]; // Control point + width?: number; +} + +``` + +Use regular VectorLayers to render the arrows: + +```jsx + + + + + +``` + ## Notes -- https://github.com/dy/bitmap-sdf -- https://github.com/maplibre/maplibre-gl-js/issues/5037 +- [https://github.com/dy/bitmap-sdf](https://github.com/dy/bitmap-sdf) +- [https://github.com/maplibre/maplibre-gl-js/issues/5037](https://github.com/maplibre/maplibre-gl-js/issues/5037) diff --git a/components/src/maplibre/ArrowSource/ArrowSource.svelte b/components/src/maplibre/ArrowSource/ArrowSource.svelte index 662a51e5..4068e88b 100644 --- a/components/src/maplibre/ArrowSource/ArrowSource.svelte +++ b/components/src/maplibre/ArrowSource/ArrowSource.svelte @@ -9,11 +9,10 @@ const { map, styleLoaded } = $derived(getMapContext()); interface ArrowSpec { - a: [number, number]; // p0 - b: [number, number]; // p2 - c: [number, number]; // p1 + a: [number, number]; + b: [number, number]; + c: [number, number]; width?: number; - debug?: boolean; } interface ArrowSourceProps {