WMS on MapKit with iOS7

Updated WMS over MapKit sample code for iOS7 , available on github  I have added cadastral maps of Czech Republic, used camera API to set the view and tested, check also WMS on Google  Maps SDK on iOS mentioned here

iOS7 introduced new class MKTileOverlay sample derives from this class WMSTileOverlay

Key method to custom tile loading (and cache control) is loadTileAtPath:result

- (void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *tileData, NSError *error))  result

this method is called by MapKit (or better by MKTileOverlayRenderer ) when it needs to draw a tile . It asks for NSData (and error) from x,y,z tile coordinates. In this method you can  load NSData either from local cache or from NSURLConnection and pass resulting NSData (when ready)  back to MapKit, for example like this (reading from cache)

result ([NSData dataWithContentsOfFile:filePath], nil);

if you do not need to use cache and you do not provide loadTileAtPath method , you can use another hook (callback) that is provided by MKTileOverlay, URLForTilePath:path

- (NSURL *)URLForTilePath:(MKTileOverlayPath)path

this method enables to custom format URL required to load tile, thus you can use WMS HTTP-GET parameters, for example :

NSString * resolvedUrl = [NSString stringWithFormat:@"%@&BBOX=%f,%f,%f,%f",self.url,left,bottom,right,top];

if there is neither method in the derived class, then you probably do not need to derive at all from MKTileOverlay and directly use it with initWithUrlTemplate (not case for WMS, but for any other x,y,z  sources)


Bad news is that  MapKit on iOS7 doesn’t support   tilt/pinch in Satellite/Hybrid mode in MapKit on iOS7


iOS7 notes

iOS7 transition guide (UI): https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/index.html

iOS7 std link problem:  found linking problem (only) on iOS7 , solution is to add libsstdc++ manually into the build phase – link as described here: http://stackoverflow.com/questions/18959691/ios7-only-stdlibc-linking-issue

Fix UI controller layout for iOS6 and iOS7:


// -- hide status bar on iOS7  - add to controller:
 - (BOOL)prefersStatusBarHidden{
 return YES;

-- not iOS7 related but useful: create cell view either from Nib or manually:
 -(CategoryCell*) createCell{
  static NSString *reuseId = @"CategoryCellIdentifier";
  CategoryCell *cell = [self.tableView dequeueReusableCellWithIdentifier:reuseId];
  if (cell == nil){
   cell =  [[UINib nibWithNibName:@"" bundle:nil] instantiateWithOwner:nil options:nil][0];
 //cell = [[CategoryCell alloc] initWithStyle:UITableViewCellStyleSubtitle  reuseIdentifier:reuseId] ;
 return cell;