我对在OpenLayers3中设置动画功能的可能性感到好奇。
我非常了解这里提供的示例http://openlayers.org/en/v3.0.0/examples/animation.html和这里https://gis.stackexchange.com/questions/26546/openlayers-animation-examples和算法
但是,OL3的官方示例不太符合我的需求。
假设我有一个图层(例如,geojson),其中的“时间”列包含很多时间值。
我想实现类似滑块的功能,该功能可以根据用户的操作来添加/删除功能(或更改其样式)。
事实是,有些API可能能够做到这一点,但它们似乎已经过时了(代码示例仍在ol2中使用)。
您是否对使用OL3构建简单的动画滑块有任何建议?
编辑:不一定必须是适当的动画。我想到的一种可能性是,每当移动滑块时,都将更改图层的样式。尽管如此,如何实现这一点仍然没有任何线索。
此图说明了我的想法:
编辑:我当前的方法是有一个滑块,每次移动它都会触发代码。我以某种方式尝试动态更改图层样式,但是仍然没有可行的结果。
好的。我自己提出了一个解决方案。这不是真正的完整动画,但对我有用。
Basically what I do is that I load a wfs-layer to my map. Now, here is the trick: When I do that, I simply sort the time-values of the features one by one and add every feature with the time value of 1 to one layer, every feature with a time value of 2 to another and so and so forth. This basically does the trick. The rest is simple.
Next step is that I implement a slider that ranges from 1 (the lowest time value) to whatever the highest time value is. Everytime the slider is moved it triggers an event that finds out to which time value the slider is set to and then adds/removes the corresponding layers.
So, if the slider is set to 5. It will add every layer from 1 to 5 to the map and remove every other layer. Again, this is not really an animation, but it does work in my case.
如果有人提出另一种可能的解决方案,请在此处发布。我会很感激的。
(顺便说一下,这就是我的解决方案的实际效果:)
编辑:我现在也可以确认使用这种方法可以构建“适当的”动画。我只是构建了一个js函数,该函数包含添加多个层时的多个“ setTimeout”,并添加了触发该函数的播放按钮。这相当于动画,可视化了从t = 1到tmax的增长。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句