Cannot get MarkerLayer to work #252
Answered
by
dimfeld
MarkR-triad
asked this question in
Q&A
-
I'm using Svelte 4 not Svelte 5 |
Beta Was this translation helpful? Give feedback.
Answered by
dimfeld
Feb 26, 2025
Replies: 1 comment 2 replies
-
|
First, I think you want something like this for the filter: ['all',
['==', 'geometry-type', 'Point'],
['==', ['get', 'prop'], value]
]References for those items in the mapbox docs (which are the same in maplibre) To your questions:
<script lang="ts">
import { mapContext, FillLayer } from 'svelte-maplibre';
export let filter;
const { map, source } = mapContext();
$: features = $map?.querySourceFeatures($source, { filter });
$: console.log(features);
</script>
<!-- Set up an invisible layer so that querySourceFeatures has something to search through. -->
<FillLayer paint={{ 'fill-opacity': 0 }} beforeLayerType="symbol" />Hope this helps! |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
MarkR-triad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First, I think you want something like this for the filter:
References for those items in the mapbox docs (which are the same in maplibre)
To your questions:
Markerinternally which expects you to provide your own content in the slot. Otherwise you end up with an emptydiv. We could probably check$$slots.defaultto see if content is provided, and useDefaultMarkerinstead if none is provided.