Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update TileOverlay without a flicker?

I have some dynamic tile content to display on top of a map (specifically, weather images -- radar, satellite, temperatures, etc.). I'm using Google Maps API for Android v2.

The problem I'm having is that apparently the only way to update the tile images (i.e. when new data arrives, or when the frame advances in a time lapse animation) is to call TileOverlay.clearImageCache. Unfortunately, when I do that, the tile overlay flickers off for a moment. This is because clearImageCache immediately removes the existing tile images from the display, but there's a delay before it can decode and display new tile images.

I'm using a custom TileProvider that caches the tile images, rather than fetching them from the server each time. But even when it's only feeding cached tiles (i.e. there's no significant delay imposed by my TileProvider.getTile implementation), there's still enough of a delay in the process that the user can see a flicker.

Does anyone know of a way to avoid this flicker? Is there some way I can double-buffer the tile overlay? I tried to double-buffer it with two TileOverlays attached to the map, one of which is invisible. But the invisible TileOverlay does not start fetching any tiles from my TileProvider -- even after I call clearImageCache.

like image 778
erickj00001 Avatar asked Jan 19 '13 00:01

erickj00001


1 Answers

Would it be possible to load the upcoming tile image however have the visibility set to false? Tile.setVisible(false);

Then when you want to change (after the upcoming tile has loaded), set the upcoming tile to be visible and the current tile to be invisible?

CurrentTile.setVisible(false); NewTile.setVisible(true); 

This way the change all occurs within the same render frame, and there is no delay waiting for cached images to load.

like image 154
Ice Phoenix Avatar answered Sep 19 '22 15:09

Ice Phoenix