deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Can I change Cursor on hover of point?

Open UttamRahane opened this issue 6 years ago • 6 comments

In Scatterplot layer, can I change cursor to pointer on hover of plotted points? ex. https://news.google.com/covid19/map

UttamRahane avatar Apr 29 '20 10:04 UttamRahane

let isHovering = false;

Deck({
  ...
  onHover: ({object}) => (isHovering = Boolean(object)),
  getCursor: ({isDragging}) => (isDragging ? 'grabbing' : (isHovering ? 'pointer' : 'grab'))
})

Pessimistress avatar Apr 29 '20 21:04 Pessimistress

Thanks @Pessimistress .

UttamRahane avatar Apr 30 '20 11:04 UttamRahane

Hey,

How does this work with DeckGL instead?

JG145 avatar Feb 15 '21 17:02 JG145

isHovering is passed to getCursor as of v8.4.

Pessimistress avatar Feb 15 '21 17:02 Pessimistress

Version 8.8.15 here. Is it possible that ScatterplotLayer doesn't implement getCursor? I needed to read 'isHovering' to change the cursor, but it seems to me that nothing changes if using it. i.e.:

getCursor: (cursor: any) => {
      console.log(cursor);
      return 'crosshair';
}

doesn't log anything, nor changes cursor to 'crosshair'.

EDIT: (I corrected my self also here Sorry, I just realized that I can use:

onHover: (info: any) => {console.log(info)}

inside the new Deck declaration and then check for info.layer.id to be or not the one I need. then I can change any variable on my needs..

I think this is not clear on the documentation.

spiderdab avatar Mar 09 '23 14:03 spiderdab

I got here because the cursor wasn't changing, but I'm using the GoogleMapsOverlay and realized I needed to change the google map cursor instead, so this worked just fine:

getCursor: ({ isHovering, isDragging }) => {
      if (isHovering) {
        map.setOptions({ draggableCursor: "pointer" });
      } else {
        map.setOptions({ draggableCursor: "" });
      }
      return "grab";
    },

chriszrc avatar May 10 '23 18:05 chriszrc