mapbox-gl-js version: v0.43.0 and master
I can reproduce with https://www.mapbox.com/mapbox-gl-js/example/animate-point-along-route/
This bug is only reproducible when the updates are spaced further apart (when the rendering is slower). I can reproduce more easily in Firefox.
Feature is animated without flickering.
Feature is animated with flickering.
The feature is flickering because it was moved far enough from the original feature that the CrossTileSymbolIndex isn't able to match it with the previous symbol. Since it is treated as a new symbol it doesn't have an opacity to copy over and so it isn't visible until the next placement happens.
Possible fixes:
cc @ChrisLoer
Does this also occur if the data is updated, let's say, only every minute and during that time a real vehicle has moved many kilometers? Implementing a key (using a property) would be an easy option - if there is a unique id available for each element in the data source.
@ttsirkia yes, it would still happen, but it would be less noticeable
Every now and then I try if it would be possible to upgrade to newer library version but this is one of the blocking issues. I have a map which shows real-time positions for trains and the data source updates every 15 seconds. During this time, trains typically move that much that labels will fade out and fade in. That distracts the user quite a lot.
Having a key for elements which are mainly updated with setData would be very useful in this kind of cases where the data constantly updates.
Another way to fix the issue would be a layer-based or a global setting to disable the fading effect.
@ttsirkia does setting icon-allow-overlap: true work as a workaround for you?
I'm using a glyph as a symbol to get an arrow which can be rotated and colored easily. That is already allowing overlapping.
Instead of using icon, use mapbox marker.
Dynamically vary the latLng of the marker by requesting animation with the help of requestAnimationFrame() function and a very smooth animation can be produced.
Works perfectly fine for me!.
The problem with mapbox icon is that its custom setData() method takes sometime to update the source and so the next animation frame is requested before the data is updated in the source.This causes flickering.
Using mapbox marker, this can be solved.
And then background-image css property can be used to assign a custom image to the marker.
Most helpful comment
Every now and then I try if it would be possible to upgrade to newer library version but this is one of the blocking issues. I have a map which shows real-time positions for trains and the data source updates every 15 seconds. During this time, trains typically move that much that labels will fade out and fade in. That distracts the user quite a lot.
Having a key for elements which are mainly updated with
setDatawould be very useful in this kind of cases where the data constantly updates.