OpenLayers循环图层功能

时间:2017-11-27 17:12:44

标签: loops openlayers tile

在OpenLayers中,我有一个按钮(显示),当我按下它时,我在地图上有一个图层

我的问题:如何以一定的帧速率显示多个图层 (像一个循环!)

1 个答案:

答案 0 :(得分:0)

每隔X秒显示一个新的/其他图层,使用setInterval

让我们假设您以某种方式得到了一个日期数组,其中包含了瓷砖,以及一个可以显示该图层的函数displayLayerByDate(dateObject)

function animatedLayers(arrayOfDates) {
  let currentIdx = 0;
  const handle = setInterval(function() {
    const currentDate = arrayOfDates[currentIdx];
    displayLayerByDate(dateObject);
  }, 5000); 
}