KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am working on an app that uses MKOverlay views to layer my own custom maps on top of the Google base map. I have been using Apple's excellent TileMap sample code (from WWDC 2010) as a guide. My problem - when "overzoomed" to a level of detail deeper than my generated tile set, the code displays nothing because there are no tiles available at the calculated Z level. The behavior I want - when "overzoomed" the app should just keep magnifying the deepest level of tiles. It is a good user experience for the overlay to become blurrier - it is a very bad experience to have the overlay vanish. Here is the code which returns the tiles to draw - I need to figure out how to modify this to cap the Z-depth without breaking the scaling of the frame being calculated for the overlay tile. Any thoughts??? - (NSArray *)tilesInMapRect:(MKMapRect)rect zoomScale:(MKZoomScale)scale { NSInteger z = zoomScaleToZoomLevel(scale); // PROBLEM: I need to find a way to cap z at my maximum tile directory depth. // Number of tiles wide or high (but not wide * high) NSInteger tilesAtZ = pow(2, z); NSInteger minX = floor((MKMapRectGetMinX(rect) * scale) / TILE_SIZE); NSInteger maxX = floor((MKMapRectGetMaxX(rect) * scale) / TILE_SIZE); NSInteger minY = floor((MKMapRectGetMinY(rect) * scale) / TILE_SIZE); NSInteger maxY = floor((MKMapRectGetMaxY(rect) * scale) / TILE_SIZE); NSMutableArray *tiles = nil; for (NSInteger x = minX; x <= maxX; x++) { for (NSInteger y = minY; y <= maxY; y++) { // As in initWithTilePath, need to flip y index // to match the gdal2tiles.py convention. NSInteger flippedY = abs(y + 1 - tilesAtZ); NSString *tileKey = [[NSString alloc] initWithFormat:@"%d/%d/%d", z, x, flippedY]; if ([tilePaths containsObject:tileKey]) { if (!tiles) { tile
Tags (comma-separated)
Save Edits
Cancel