Reputation: 15881
I'm implementing a map application similar to the maps app and I'm try to add zooming. I have multiple detail levels, e.g. 6, and I want to use the appropriate level for the current zoom scale. I'm using a CATiledLayer in a UIScrollView. So far I can set the min/max zoom in the UIScrollView, drawLayer gets called and I draw the appropriate tile, but this only uses my first map level. Now I want to set levelsOfDetail in the CATiledLayer so I can use the appropriate detail level.
My question is, how do I know at what level I should draw? The tileSize of CATiledLayer is always the same, and so is the clipping rect. I can see when drawLayer gets called for the new level of detail, but how to tell what level that is.
Upvotes: 2
Views: 1665
Reputation: 1492
Set the levelsOfDetail and Bias up front. Then when called to draw, look at the frame of the view being zoomed by the scroll view, and compare it against the bounds. That should give you the information needed to determine what you draw. Also look at the clip path bounds to see "where" the CATiledLayer is working on next.
Upvotes: 3