简体   繁体   English

如何降低OpenLayers 3的所有缩放速度?

[英]How can I slow all zooming in OpenLayers 3?

I built an OpenLayers 3 map. 我建立了一个OpenLayers 3地图。 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. 较长的动画持续时间和/或分数缩放方法(每个事件的缩放比例小于1)会有所帮助。 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 : 您可以在ol.control.Zoomol.interaction.MouseWheelZoomol.interaction.DoubleClickZoomol.interaction.KeyboardZoom上自定义duration属性:

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
}));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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