Skip to content

How to getCursor for an individual Layer #1647

Answered by gala-m
gala-m asked this question in Q&A
Discussion options

You must be logged in to vote

I found a work-around for my problem. I was not using any popups, but see if this is useful to you.

I changed the cursor manually by listening for when the mouse hovered over the specific layer.

Here, set the normal pointer:

const [pointer, setPointer] = useState(() => 
    ({isHovering, isDragging}) => isDragging ? 'grabbing' : isHovering ? 'grab' : 'grab'
)

The id of my layerStyle is 'points'.

This is the function that the ReactMapGL calls when any part/layer of the map is hovered:

const onHover = useCallback(event => {
    const feature = event.features && event.features[0];

    if (feature && feature.layer.id === "points") {
        setPointer(() => 
            ({isHovering, isDrag…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by gala-m
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