Skip to content

Commit 60cedaf

Browse files
authored
fix(VectorLayer): Fix default value for placeBelow pointing to a layer that doesn't exist anymore (#143)
* Fix default value for placeBelow * Improve formatting, mark optional props as such * Rebuild lockfile
1 parent df5bfda commit 60cedaf

6 files changed

Lines changed: 14 additions & 65 deletions

File tree

components/src/maplibre/GeoJSONSource/GeoJSONSource.stories.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<GeoJSONSource id="demo" data={geoJSON} attribution="Demo attribution" />
4141
<VectorLayer
4242
sourceId="demo"
43+
placeBelow="street-residential"
4344
id="test-outline"
4445
type="line"
4546
paint={{

components/src/maplibre/GeoJSONSource/GeoJSONSource.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
2121
const sourceSpec: GeoJSONSourceSpecification = {
2222
type: 'geojson',
23-
data,
2423
maxzoom: maxZoom,
25-
attribution
24+
attribution,
25+
data
2626
};
2727
</script>
2828

components/src/maplibre/Source/MapSource.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { type Map, type SourceSpecification } from 'maplibre-gl';
44
import { getMapContext, createSourceContext } from '../context.svelte.js';
55
6-
type Source = maplibregl.VectorTileSource;
6+
type Source = maplibregl.VectorTileSource | maplibregl.GeoJSONSource;
77
88
interface MapSourceProps {
99
id: string;
@@ -35,7 +35,10 @@
3535
3636
// 2. Do extra stuff with the source object
3737
$effect(() => {
38-
if (source) {
38+
if (source && sourceSpec.type === 'geojson') {
39+
if (!firstRun) {
40+
source.setData(sourceSpec.data);
41+
}
3942
}
4043
});
4144

components/src/maplibre/VectorLayer/VectorLayer.stories.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
/>
2525
<VectorLayer
2626
sourceId="ev-infra-source"
27+
sourceLayer="coverage"
2728
type="fill"
2829
id="coverage-fill"
29-
sourceLayer="coverage"
3030
placeBelow="street-residential"
3131
paint={{
3232
'fill-color': [

components/src/maplibre/VectorLayer/VectorLayer.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
sourceId: string;
2323
sourceLayer?: string;
2424
type: 'line' | 'fill' | 'circle' | 'symbol';
25-
placeBelow: string;
25+
placeBelow?: string;
2626
visible?: boolean;
2727
minZoom?: number;
2828
maxZoom?: number;
@@ -31,16 +31,16 @@
3131
hovered?: MapGeoJSONFeature | undefined;
3232
selected?: MapGeoJSONFeature | undefined;
3333
34-
onclick: (e: MapLayerMouseEvent) => any;
35-
onmousemove: (e: MapLayerMouseEvent) => any;
36-
onmouseleave: (e: MapLayerMouseEvent) => any;
34+
onclick?: (e: MapLayerMouseEvent) => any;
35+
onmousemove?: (e: MapLayerMouseEvent) => any;
36+
onmouseleave?: (e: MapLayerMouseEvent) => any;
3737
}
3838
const {
3939
id,
4040
sourceId,
4141
sourceLayer,
4242
visible = true,
43-
placeBelow = 'label-place-capital',
43+
placeBelow = 'label-place-major-city',
4444
type,
4545
paint,
4646
layout,

package-lock.json

Lines changed: 0 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)