diff --git a/components/src/index.js b/components/src/index.js index a3e4ba1d..24c9cdf6 100644 --- a/components/src/index.js +++ b/components/src/index.js @@ -34,7 +34,9 @@ export { default as GeocoderControl } from './maplibre/GeocoderControl/GeocoderC export { default as NavigationControl } from './maplibre/NavigationControl/NavigationControl.svelte'; export { default as ScaleControl } from './maplibre/ScaleControl/ScaleControl.svelte'; export { default as VectorLayer } from './maplibre/VectorLayer/VectorLayer.svelte'; +export { default as HillshadeLayer } from './maplibre/HillshadeLayer/HillshadeLayer.svelte'; export { default as VectorTileSource } from './maplibre/VectorTileSource/VectorTileSource.svelte'; +export { default as RasterDEMSource } from './maplibre/RasterDEMSource/RasterDEMSource.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'; diff --git a/components/src/maplibre/ArrowSource/ArrowSource.svelte b/components/src/maplibre/ArrowSource/ArrowSource.svelte index dd8139ad..14faaf81 100644 --- a/components/src/maplibre/ArrowSource/ArrowSource.svelte +++ b/components/src/maplibre/ArrowSource/ArrowSource.svelte @@ -32,13 +32,13 @@ const { id, arrows = [], attribution = '' }: ArrowSourceProps = $props(); - const ars: JsonArrow[] = arrows.map((a) => { + const ars: JsonArrow[] = $derived(arrows.map((a) => { return { width: a.width || 10, points: quadraticToPoints(a.a, a.b, a.c), headScale: a.headScale }; - }); + })); const arrowsToJson = (arrows: JsonArrow[] = []) => { if (!map) return { type: 'FeatureCollection', features: [] } as GeoJSON.GeoJSON; @@ -83,6 +83,7 @@ }; let sourceSpec: GeoJSONSourceSpecification = $state({ + // svelte-ignore state_referenced_locally attribution, type: 'geojson', promoteId: 'id', diff --git a/components/src/maplibre/GeoJSONSource/GeoJSONSource.svelte b/components/src/maplibre/GeoJSONSource/GeoJSONSource.svelte index 7be2f3a4..1803e942 100644 --- a/components/src/maplibre/GeoJSONSource/GeoJSONSource.svelte +++ b/components/src/maplibre/GeoJSONSource/GeoJSONSource.svelte @@ -2,18 +2,13 @@ // See: https://maplibre.org/maplibre-gl-js/docs/API/classes/GeoJSONSource/ import { type GeoJSONSourceSpecification } from 'maplibre-gl'; import MapSource from '../Source/MapSource.svelte'; + import type { SourceProps } from '../types'; - interface GeoJSONSourceProps { - id: string; + interface GeoJSONSourceProps extends Omit { /** * GeoJSON object or URL */ data: GeoJSON.GeoJSON | string; - /** - * Attribution string for your data, usually rendered using an `` - */ - attribution?: string; - maxZoom?: number; /** * Use a field from the feature data for IDs. Must coerce to integer. */ @@ -35,7 +30,7 @@ generateId = false }: GeoJSONSourceProps = $props(); - const sourceSpec: GeoJSONSourceSpecification = { + const sourceSpec: GeoJSONSourceSpecification = $derived({ type: 'geojson', maxzoom: maxZoom, attribution, @@ -43,7 +38,7 @@ generateId, lineMetrics, data - }; + }); diff --git a/components/src/maplibre/HillshadeLayer/HillshadeLayer.mdx b/components/src/maplibre/HillshadeLayer/HillshadeLayer.mdx new file mode 100644 index 00000000..4c6c83ad --- /dev/null +++ b/components/src/maplibre/HillshadeLayer/HillshadeLayer.mdx @@ -0,0 +1,13 @@ + +import { Meta } from '@storybook/addon-docs/blocks'; +import { Story, Primary, Controls, Stories } from '@storybook/addon-docs/blocks'; +import * as HillshadeLayerStories from './HillshadeLayer.stories.svelte'; + + + +# HillshadeLayer + +Experimental hilshade layer. Uses a `raster-dem` source to render real-time raster hillshading. + + + diff --git a/components/src/maplibre/HillshadeLayer/HillshadeLayer.stories.svelte b/components/src/maplibre/HillshadeLayer/HillshadeLayer.stories.svelte new file mode 100644 index 00000000..437e8295 --- /dev/null +++ b/components/src/maplibre/HillshadeLayer/HillshadeLayer.stories.svelte @@ -0,0 +1,46 @@ + + + + +
+ + + + + + +
+
+
+ + diff --git a/components/src/maplibre/HillshadeLayer/HillshadeLayer.svelte b/components/src/maplibre/HillshadeLayer/HillshadeLayer.svelte new file mode 100644 index 00000000..421bd5f2 --- /dev/null +++ b/components/src/maplibre/HillshadeLayer/HillshadeLayer.svelte @@ -0,0 +1,51 @@ + diff --git a/components/src/maplibre/HillshadeLayer/index.js b/components/src/maplibre/HillshadeLayer/index.js new file mode 100644 index 00000000..d69c1f5a --- /dev/null +++ b/components/src/maplibre/HillshadeLayer/index.js @@ -0,0 +1,2 @@ +import HillshadeLayer from './HillshadeLayer.svelte'; +export default HillshadeLayer; diff --git a/components/src/maplibre/RasterDEMSource/RasterDEMSource.svelte b/components/src/maplibre/RasterDEMSource/RasterDEMSource.svelte new file mode 100644 index 00000000..95b607dd --- /dev/null +++ b/components/src/maplibre/RasterDEMSource/RasterDEMSource.svelte @@ -0,0 +1,38 @@ + + + diff --git a/components/src/maplibre/RasterDEMSource/index.js b/components/src/maplibre/RasterDEMSource/index.js new file mode 100644 index 00000000..4c6895d6 --- /dev/null +++ b/components/src/maplibre/RasterDEMSource/index.js @@ -0,0 +1,2 @@ +import RasterDEMSource from './RasterDEMSource.svelte'; +export default RasterDEMSource; diff --git a/components/src/maplibre/Source/MapSource.svelte b/components/src/maplibre/Source/MapSource.svelte index d1596f2f..9d535ed7 100644 --- a/components/src/maplibre/Source/MapSource.svelte +++ b/components/src/maplibre/Source/MapSource.svelte @@ -1,12 +1,12 @@