I'm trying to update my tile map code to use iOS 7's MKTileOverlay
and MKTileOverlayRenderer
, and I could use some pointers for making things work better.
First, here is the iOS6 code: AppleTileOverlay.m and TileOverlayView.m. This still works quite well in iOS 7 when when I replace TileOverlayView
with a class that is identical in all ways except that it's a subclass of MKOverlayRenderer
instead of MKOverlayView
.
The new piece I'm testing is a subclass of MKTileOverlay
with the only method being:
-(NSURL *)URLForTilePath:(MKTileOverlayPath)path {
NSString *tileKey = [[NSString alloc] initWithFormat:@"%d%d%d", path.x, path.y, path.z];
NSString *tilePath = [[NSBundle mainBundle] pathForResource:tileKey ofType:nil inDirectory:@"TileFolder"];
NSURL *url;
if (tilePath) {
url = [NSURL fileURLWithPath:tilePath];
}
return url;
}
The map tiles load fine most of the time, but the log fills up with messages like this:
Error loading URL (null): Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x1b3e19e0 {NSUnderlyingError=0x1894d470 "bad URL", NSLocalizedDescription=bad URL}
from the method returning nil for the URL.
So the question is: Can I avoid those error messages, or should I just stick with the older overlay class I have?