Closed MauroIT closed 4 years ago
You have to add the feature to the layer otherwise Openlayers optimizes rendering and doesn't draw the layer.
Remove it on animation end (use animationend
event).
NB: using ol6 featureAnimation on maps should be deprecated as there is no more global canvas to draw the animation (ol-ext tries to animate on the top layer but optimisation make it unsafe). I recommend using featureAnimation on layers (create an Overlay on top top play animation).
var overlay = new ol.layer.Vector({
source: new ol.source.Vector()
});
overlay.setMap(map);
var animation = new ol.featureAnimation.Zoom({
fade: ol.easing.easeOut,
duration: 3000,
easing: ol.easing[$("#easing").val()]
});
animation.on('animationstart', function(e) {
overlay.getSource().addFeature(e.feature);
});
animation.on('animationend', function(e) {
overlay.getSource().removeFeature(e.feature);
});
overlay.animateFeature (f, animation);
I'll change the example to reflect this.
Hi Viglino, thanks for your reply! I have implemented according your suggestion. The animation works now.
Hello,
I've changed the code for map animation. Now it creates its own animation overlay and animate feature on it.
Just use map.animateFeature
.
When calling the
map.animateFeature
method while the last added vector layer does not contain any features, the layer'spostrender
event will never be fired and consequently no animation will be shown on the map.To reproduce this beheavior you can simply adjust the map.Pulse example code as follows:
Replace
with