A background "flashes" when zoom levels switch #96

amjaliks opened this Issue Feb 27, 2011 · 5 comments


None yet
6 participants

amjaliks commented Feb 27, 2011

A background appears for a short while, when one zoom level switches to another. It creates an effect, like screen is flashing.


hjon commented Mar 5, 2011

I have noticed this as well. I'm not absolutely certain why this happens, but I suspect that it is due to the way tiles are displayed. Here's my best shot at describing it:

  1. At zoom level x, Route-Me uses CALayer subclasses to display each tile for that zoom level. Each of these layers has a "fade"-type animation set whenever the contents change.
  2. When the zoom level changes to level y, Route-Me starts loading tiles for zoom level y
  3. As the new tiles come in, Route-Me creates new layers for zoom level y. These layers replace the layers at zoom level x as they are available.

I believe Route-Me is removing the layers from the previous zoom level (level x) before displaying the layers from the new zoom level (level y). Thus, the old layers fade to the background color/image before that fades into the new layers, rather than fading directly into the new layers.

This may not be completely accurate, as I haven't fully understood the investigating I did, but at the least, I don't believe it's as simple as setting the correct animation on the layers. It's a deeper architecture issue.

I have investigated this a bit. The easiest way to reproduce it is to set the background color to black. That makes it easy to see. Then zoom in and it will "flash" for each zoom. A part of the problem I think is in
RMTileImage.m on the following line:
fadein.type = kCATransitionReveal;

it should instead be:
fadein.type = kCATransitionFade;

It definitely make things better. It doesn't solve the flashing fully but now it's only visible when the new tile(s) needs to be downloaded and are not in the cache but maybe that is inevitable!?


incanus commented Apr 12, 2011

So I had a way of doing this in our custom fork for a while before it was added to route-me. This was accomplished not in -[RMTileImage makeLayer] using the contents key and kCATransitionReveal but instead in a custom subclass of RMCoreAnimationRenderer in tileAdded:WithImage: using the sublayers key and kCATransitionFade. I have requested a pull here that brings this in. Another nice thing about doing it here is the possibility of adding a BOOL flag at the renderer level, instead of per-tile, to turn the fade animation on or off as needed.

servine commented Apr 13, 2011

If you are after smooth zooming then you need look no further than setting the tileDepth property on RMMapContents which for example if set to 2 will keep the tile levels on either side of your current zoom level loaded and will not disappear until it the tiles for that zoom level has been loaded.

[self.contents setTileDepth:2];


vyskocil commented Apr 13, 2011

I copy here what I just wrote in the pull request comments, it is saying much the same as servine said in the previous comment :

I tried the patch but I hadn't experienced much improvement, perhaps you did other tweaks to have better results ?
I experienced the best results when I replace kCATransitionReveal with kCATransitionFade in RMTileImage.m and set mapView.contents.tileDepth to 2. With these changes the new tiles are blended like if it there is 'mipmapping' in action.

@mvasilak mvasilak added a commit to mvasilak/route-me that referenced this issue Apr 20, 2011

@mvasilak Justin R. Miller + mvasilak fixes #96: replace tile-based reveal with renderer-based fade bdd5cf4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment