Replies: 1 comment
-
This could be accomplished with a const [didPress, setDidPress] = useState(false);
const featureCollection = useMemo(() => {
return turf.featureCollection(
features.map((f) => {
return {
...f,
properties: {
did_press: didPress,
}
};
})
);
}, [didPress]);
return (
<MapboxGL.ShapeSource
shape={featureCollection}
...
>
<MapboxGL.SymbolLayer
...
style={{
iconOpacity: ['case', ['to-boolean', ['get', 'did_press']], 0.5, 1],
}}
aboveLayerID={mapLayerId}
/>
</MapboxGL.ShapeSource>
); Check out https://docs.mapbox.com/style-spec/reference/expressions for explanation of the style expression. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all, I was wondering how can I implement the
setFeatureState
method?const mapRef = useRef(null)
using theuseRef
hook and set it inside theMapView
component,ref={mapRef}
mapRef.current.setFeatureState()
through anonPress
callback function, but it does not work.TypeError: mapRef.current.setFeatureState is not a function (it is undefined), js engine: hermes
as an error.Any ideas or input would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions