简体   繁体   中英

How can I slow all zooming in OpenLayers 3?

I built an OpenLayers 3 map. I love it, but I feel that the zooming is too fast. I can't find a way to slow it down. A longer animation duration and/or a fractional-zoom approach (zooming by less than 1 for each event) would help. How can I implement these changes?

You can customize the duration property on ol.control.Zoom , ol.interaction.MouseWheelZoom , ol.interaction.DoubleClickZoom and ol.interaction.KeyboardZoom :

var duration = 1000; // 1 second
map.addControl(new ol.control.Zoom({
  duration: duration
}));
map.addInteraction(new ol.interaction.MouseWheelZoom({
  duration: duration
}));
map.addInteraction(new ol.interaction.DoubleClickZoom({
    duration: duration
}));
map.addInteraction(new ol.interaction.KeyboardZoom({
    duration: duration
}));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM