OpenLayers3 - animated .fit to some extent

I created a map using OpenLayers3. I can successfully scale to a layer on the map using the following code:

map.getView().fit(extent, map.getSize());

However, I looked like something similar in an animated way.

I know about the following animations:

ol.animation.pan
ol.animation.zoom

Using them, I cannot scale to level using ol.animation.pan. I can only pan to a point (and not limit) and use ol.animation.zoom. I can scale to resolution (and not to the bounding box). So I'm looking for animated .fit, so I can scale the animation to some extent.

Any suggestions on how I can achieve this would be appreciated :)

+4
source share
2

v3.20.0, OpenLayers duration ol.View#fit(). 1- , 1000:

// OpenLayers v3.20.x
view.fit(extent, size, {duration: 1000});

, v3.21.0 API ol.View#fit() - ( ):

// OpenLayers >= v3.21.0
view.fit(extent, {duration: 1000});
+3

var view = map.getView()
var pan = ol.animation.pan({ source: view.getCenter() });
var zoom = ol.animation.zoom({ resolution: view.getResolution() });
map.beforeRender(pan, zoom);
view.fit(extent, map.getSize())
0

All Articles