1

I need to place an image as an arrow and change the rotation depending on the mouse cursor. I have decided to use Icon object.

import {Icon} from 'ol/style.js';

const icon =new Icon({
  anchor: [0.5, 46],
  anchorXUnits: 'fraction',
  anchorYUnits: 'pixels',
  src: 'data/icon.png',
});

Is it possible to bind a JS mouse event to ab icon? (mousemove, mouseup, mouseleave)?

1 Answer 1

0

You can do something like:

map.on('pointermove', event => {
  window.map_hover_latest = event
})

that will get you the current position of the cursor to work with.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.