TransWikia.com

Openlayers-6 .fit(extent, {options}) not working with options

Geographic Information Systems Asked on February 11, 2021

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();
map.getView().fit(extent);
//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.

One Answer

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().fit(geometry);
    map.getView().animate({ center: geometry }, { duration: 750 });
    //map.getView().setZoom(currentZoom);                    
}

OpenLayers animate()

Answered by Roger on February 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP