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
Reblogged this on jailbr0keni0s's Blog.
Are you available for a few hours of consultation work related to this WMS over MapKit sample? Please contact me if so.
you can post your question here or on github where this sample is posted.
I have a problem i cant figure out …
i need to load a wms on top of mapkits map, as you do in the video… but it is so not working..
let url = “http://kortforsyningen.kms.dk/service?login=xxx&password=xxxx&SERVICENAME=topo_skaermkort&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&bbox=280497,6529440,2203040,8549830&width=250&height=250&LAYERS=dtk_skaermkort&styles=&format=image/jpeg&jpegquality=80&styles=&exceptions=application/vnd.ogc.se_inimage&tilesOrigin=280497,6529440&displayOutsideMaxExtent=true&tiled=true”
var tileOverLay = MKTileOverlay(URLTemplate:url)
tileOverLay.canReplaceMapContent = true
Is it possible to get your expertise for som hours??
Pingback: 国土地理院 地図 | iPhoneDeveloper