I have a list of coordinates I want my code to pan through. I can place view.animate and do it once to pan from my current center to the first coordinate but not to keep cycling through the list. Any ideas? I got the idea from this https://openlayers.org/en/latest/examples/animation.html.
var coordinates = [london, moscow, istanbul, rome, bern]; (they have their coordinates)
var view = new ol.View({
center: istanbul,
zoom: 4
})
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})],
loadTilesWhileAnimating: true,
view: view
});
coordinates.forEach(function(element) {
setTimeout(view.animate({
center: element,
duration: 2000,
}), 10000);
});