I'm developing integration between google maps and openlayers 4. I based my work on this example from documentation for openlayers 3.
My problem is that somewhere between ol 3 and ol 4.4.2 behaviour of change:resolution
event was changed. Previously this code
view.on('change:resolution', () => {
console.log(view.getZoom())
})
was only called once per mouse wheel rotation and logged (for example):
5
and now it produces something like this:
4.017277252772164
4.08563754449778
4.152661471658049
4.522609511830051
4.691606503462093
4.793368457643155
4.891103916717288
4.980192777999678
4.999621855713164
5
So when I try to synchronize zoom between google map and openlayers (like in the example) it causes google map to flash on every zoom. It seems that google map doesn't support fractional values for zoom.
Can I either restrict openlayer zoom values to integers or do some work around?
I tried to use ceil/floor values of openlayers zoom when calling googleMap.setZoom
but because zooming also involves changes of center location it results in jerky, unpleasant behaviour.