Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change pointer when hovering over feature #1259

Closed
steff-o opened this issue May 10, 2021 · 0 comments · Fixed by #1292
Closed

Change pointer when hovering over feature #1259

steff-o opened this issue May 10, 2021 · 0 comments · Fixed by #1292

Comments

@steff-o
Copy link
Contributor

steff-o commented May 10, 2021

Is your feature request related to a problem? Please describe.
It is not obvious for the user that a feature is clickable to get featureinfo.

Describe the solution you'd like
The mouse pointer should change to 'pointer' when hovering over an area in the map where the user can click to get featureinfo.

Describe alternatives you've considered
The following code can be added whithout changes to Origo, but it would be nice if it was a feature of origo.

The code snippet only works on WMS-layers if the layer has the setting className set to a unique value, otherwise it produces false positives on other layers around WMS-features (don't know why, it's documented briefly in OL documentation for foEachLayerAtPixel).

Also it only works on visible symbols where there actually is a pixel, so it won't work on hollow area symbols and hatched areas becomes "nervous".

let pointerActive = true;
document.addEventListener('enableInteraction', evt => pointerActive = evt.detail.interaction !== 'editor');

 viewer.getMap().on('pointermove', e => {
   if (!pointerActive || e.dragging) return;
   e.map.getViewport().style.cursor = viewer.getMap().forEachLayerAtPixel(e.pixel, () => true, { layerFilter: (l) => l.get('queryable') }) ? 'pointer' : '';
            });

Additional context
Add any other context or screenshots about the feature request here.

steff-o pushed a commit to ornskoldsvikskommun/origo that referenced this issue Jun 11, 2021
steff-o pushed a commit to ornskoldsvikskommun/origo that referenced this issue Aug 10, 2021
…e classes for layers and replaced with a shared class for all clickable layers.

Also renamed option to changePointerOnHover.
steff-o pushed a commit to ornskoldsvikskommun/origo that referenced this issue Sep 2, 2021
tonnyandersson pushed a commit that referenced this issue Sep 2, 2021
* #1259 Added link pointer when hovering over clickable feature in map.

* #1259 Changed requirement for pointer to not require separate classes for layers and replaced with a shared class for all clickable layers.

Also renamed option to changePointerOnHover.

* #1259 Lint...

Co-authored-by: Stefan Forsgren <stefan@forsgren@xlent.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants