Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions components/src/maplibre/VectorLayer/VectorLayer.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@
</DesignTokens>
</Story>

<Story asChild name="feat/341">
<DesignTokens theme="light">
<div class="container">
<Map showDebug={true} style={SWRDataLabLight({ places: { showLabels: false } })}>
<GeoJsonSource id="demo" data={SamplePoints as GeoJSON} attribution="Demo attribution" />
<VectorLayer
sourceId="demo"
id="circles"
type="circle"
paint={{
'circle-radius': 12,
'circle-color': 'red'
}}
/>
<AttributionControl position="bottom-left" />
</Map>
</div>
</DesignTokens>
</Story>

<Story asChild name="Filter">
<DesignTokens theme="light">
<div class="controls">
Expand Down
15 changes: 8 additions & 7 deletions components/src/maplibre/VectorLayer/VectorLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
sourceId,
sourceLayer,
filter,
visible = true,
placeBelow = 'label-place-major-city',
placeBelow,
type,
paint,
layout,
Expand Down Expand Up @@ -80,15 +79,17 @@
$effect(() => {
if (map && styleLoaded) {
const style = map.getStyle();
beforeId = style.layers.find((l) => {
return l.id === placeBelow;
})?.id;
beforeId = placeBelow
? style.layers.find((l) => {
return l.id === placeBelow;
})?.id
: undefined;
}
});

$effect(() => {
if (map && styleLoaded && beforeId) {
map.addLayer(layerSpec, beforeId);
if (map && styleLoaded) {
beforeId ? map.addLayer(layerSpec, beforeId) : map.addLayer(layerSpec);
}
});

Expand Down