在OpenLayers中平滑缩放和平移?

时间:2013-05-11 18:16:03

标签: zoom openlayers smooth pan

我想知道,http://www.win.tue.nl/~vanwijk/zoompan.pdf中描述的平滑缩放和平移是否已在OpenLayers中实现?

已针对PolyMaps实施:http://bl.ocks.org/RandomEtc/600144 和ModestMaps:https://github.com/stamen/modestmaps-js/tree/master/examples/zoompan

1 个答案:

答案 0 :(得分:1)

自3.20.0以来,OpenLayers采用ol.View.animate()方法,可以平滑缩放和/或平移(以及其他方式),并弃用旧的ol.animation

来自latest API docs

  

视图的中心缩放(或分辨率)和旋转可以设置动画用于视图状态之间的平滑过渡。

因此,您可以通过执行以下操作缩放和平移

var view = map.getView();
view.animate({
    center: coordinates,
    zoom:   zoomLevel
});