I have a map in my angular
application OpenLayers
map.
During the test using testcafe
, I have to zoom out, but I have no way how to do that.
I only have to put my mouse at the center of the screen, and then scroll down to zoom out.
Already tried using ClientFunction
with scrollBy
and etc but nothing happens in map.
Thank you
Asked
Active
Viewed 305 times
0

Alex Skorkin
- 4,264
- 3
- 25
- 47

David Oz
- 73
- 1
- 9
-
You could use the OpenLayers view adjustZoom method https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#adjustZoom e.g. `map.getView().adjustZoom(-1)` to zoom out 1 level – Mike Feb 15 '21 at 15:54
-
@Mike Thanks but I have no access to the map. I'm in a separate project, doing tests – David Oz Feb 15 '21 at 15:57
1 Answers
1
Find out on which element the handler you need hangs and what event it listens to. This is most likely a 'mousewheel' event. This should help you:
const zoom = ClientFunction(zoomSize => {
const event = new WheelEvent('wheel', { deltaY: zoomSize });
document.querySelector('#zommed-element').dispatchEvent(event);
});

Ilya Afanasenko
- 517
- 2
- 7