Ask Your Question
1

How to bring in ES modules for ol.events.condition.shiftKeyOnly in OpenLayers?

asked 2023-06-04 11:36:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-04 11:45:02 +0000

plato gravatar image

To bring in ES modules for ol.events.condition.shiftKeyOnly in OpenLayers, you need to import the module from the ol/events/condition/ShiftKeyOnly.js file. You can do this with the following code:

import ShiftKeyOnly from 'ol/events/condition/ShiftKeyOnly';

// Use ShiftKeyOnly as a condition in your map event listener like this:
map.on('click', (evt) => {
    if (ShiftKeyOnly(evt)) {
        // Do something if the shift key was held down during the click event
    }
});

Note that you need to have installed OpenLayers as an npm package or have the source files in your project folder for this to work.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-04 11:36:00 +0000

Seen: 27 times

Last updated: Jun 04 '23