Skip to content

highlight selected feature #2173

Answered by rastapasta
PhBrz asked this question in Q&A
Aug 29, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Aloha @hamburger1993,

this can easily be achieved by adding another CircleLayer with a filter for the selected cluster id.
Store the selectedCluster in a state and add

<MapboxGL.CircleLayer
    id="clusteredPointsSelected" 
    aboveLayerID="clusteredPoints"
    filter={['==', 'cluster_id', selectedCluster ? selectedCluster.properties.cluster_id : '']}
    style={layerStyles.clusteredPointsActive} />

and define the clusteredPointsActive style as desired.

If you wish to "highlight" multiple selected features, adapt the filter to using in and an array of corresponding values.

Enjoy and happy mapping :)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@PhBrz
Comment options

Answer selected by PhBrz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants