I have upgrade openlayers in IONIC V3 app from 4.6.5 to 6.1.0. Now map.getView().fit(extent, {duration:1000}) stop working, when i remove the options object it works fine.

Am i doing something wrong or anything else is needed.?

var extent;
extent = s_layer.getSource().getFeatures()[0].getGeometry().getExtent();
//this works fine.

map.getView().fit(extent, {duration: 1000});
//Doesn't fit the extent,just a slight movement on map.

I want to achieve a slight animation on map, when fit the extent of feature. Also tried animate() method of view class but not able to get the desired results.

  • I use it so: var view = new ol.View({ ... }); map.setView(view); view.fit(extent, {duration: 1000});´ and it works by me with v6.1.0. And the options size: map.getSize(), "padding" and "maxZoom" works also. But with map.getView().fit()` it works by me also.
    – Suka
    Nov 14 '19 at 12:46

I was having the same problem. I ended up using .animate() and had to remove setZoom() because that is one of the functions that will stop the animation.

if (text == currentManhole) {
    var geometry = feature.getGeometry().getCoordinates();
    map.getView().animate({ center: geometry }, { duration: 750 });

OpenLayers animate()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.