mapbox-gl-js
mapbox-gl-js copied to clipboard
Zoom controls don't work if onZoom is calling
mapbox-gl-js version: "^2.9.1"
browser: Version 106.0.5249.119 (Official Build) (x86_64)
Steps to Trigger Behavior
- have zoom controls on the map
- use onZoom for adding pitch on zoom action
Link to Demonstration
https://codepen.io/anna-visarsoft/pen/jOxojJv?editors=0010
Expected Behavior
controls work fine
Actual Behavior
controls don't work
Yeah, this looks like a bug. The underlying issue is that all map view setters like setPitch
first stop animations with map.stop()
before doing the change, but apparently this interferes with zoom if done on the zoom
event. A temporary workaround for you (while we look for a way to fix this) is to change the code like this:
function onZoom () {
map.transform.pitch = lerp(0, 70, smoothstep(10, 15, map.getZoom())); // instead of `map.setPitch`
}
@mourner thanks! map.transform.pitch
works for me =)