如何在 OL3 中的动画后获得“结束"分辨率? [英] How to get the 'end' resolution after an animation in OL3?

查看:66
本文介绍了如何在 OL3 中的动画后获得“结束"分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 OpenLayers 3.20change:resolution 事件在 ol.View 上进行动画时被多次触发.在该版本之前,它曾经只被触发一次.change:center 也是如此.

With OpenLayers 3.20, the change:resolution event is fired multiple times while an animation is progress on the ol.View. Prior to that version, it used to be fired only once. That was also true for change:center.

我的问题是:有没有办法知道动画何时开始(这将是我想绑定某种事件侦听器的钩子)并从那里获得动画结束时的分辨率?基本上,我想知道是否有可能在 3.20 之前获得以前的行为.

My question is this: is there a way to know when an animation begins (that would be the hook I would like to bind some sort of event listener) and from there get the resolution at the end of the animation? Basically, I want to know if it's possible to get the previous behaviour prior to 3.20.

推荐答案

是的,如果您使用的是 ol.View#animate —动画结束时使用回调:

Yes, there's a way if you're using ol.View#animate — use a callback when the animation ends:

map.getView().animate({
  center: ol.proj.fromLonLat([37.6178, 55.7517]),
  zoom: 5
}, animateCallback);

function animateCallback (complete) {
  if (complete) {
    console.log(map.getView().getResolution());
    console.log(map.getView().getZoom());
  }
}

https://jsfiddle.net/jonataswalker/jr0d7dLb/

这篇关于如何在 OL3 中的动画后获得“结束"分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆