Flyover mode in Apple Maps allows AR/VR style interaction. This is not by default available for iOS developers using underlaying MapKit/ARKit technology. However it is possible to test it and the following short video is about this proof of concept – viewing cadastral maps (iKatastr) in VR like experience on iPad . Btw. Flyover mode on iOS 11 has some strange handling of overlays – described here so loading of tiles is little bit tricky. The iOS 10 version was much more better (check the video here)
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
- (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 :
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
I have crafted really simple and quick code at ESA App dev camp for viewing WMS sources. And as few people questioned me on how to do this, I am posting the full code of the MapView component that takes sample WMS service (Ozone) and overlays this above MapKit.
#1. that sample code uses experimentaly MKNetworkKit, which has some occasional troubles. You can replace the download method in WMSOverlayView class downloadTile
#2 it uses simple hash for storing tiles on cache.
I have just release iKatastr2 app on AppStore (free) that might be useful for you to look at as it uses WMS sources and custom tile loading on top of google.
App does simple stuff – shows cadastral information by tapping on cadastral map of the Czech Republic.
As all is driven by JSON configuration it is quite easy to render similar information from other sources.
MapKit sends duplicate requests for CanDraw. Duplication found is 10 of 20 tiles (full iPad screen) are sent twice. Very interesting is that drawRect in base map does that too (duplicated request is sent from the second running thread )
MapKit is using CATiledLayer underneath
Don’t do copy-paste 2 loops (see MapTile WWDC 2010 sample project from Apple) if your tiles fits exactly to the matrix of the Google tiles
// for (NSInteger x = minX; x < = maxX; x++) {{
//for (NSInteger y = minY; y < = maxY; y++) }}
I have searched this and couldn’t find any answer, so here is my own research so far on this subject. You can disable MapKit base layers using 3 approaches:
#1 remove subview from MKMapView (quite bad as you will loose all overlays too)
#2 use undocumented function (bad too as this will be rejected by Apple approval process):
// get MKMapTileView from view hierarchy
UIView * mkMapTileView = [((UIView*) [ ((UIView*)[self.subviews objectAtIndex:0]).
subviews objectAtIndex:0]).subviews objectAtIndex:0];
// call undocumented method
if ( [mkMapTileView respondsToSelector:@selector(setDrawingEnabled:)]){
[mkMapTileView performSelector:@selector(setDrawingEnabled:) withObject:(id) NO];
#3 use method swizzle
inspired by http://www.mikeash.com/pyblog/friday-qa-2010-01-29-method-replacement-for-fun-and-profit.html
this method is fine as it is official method and enables you to ‘subclass’ a class that you don’t have access in compile time.
#import <objc/runtime.h>
// original method declaration
static void (*_origDrawLayerInContext)(id, SEL, CALayer*, CGContextRef);
// set up subclass in runtime..in some entering method
UIView * mkMapTileView = [((UIView*) [ ((UIView*)[self.subviews objectAtIndex:0]). subviews objectAtIndex:0]).subviews objectAtIndex:0];
Method origMethod = class_getInstanceMethod([mkMapTileView class], @selector(drawLayer:inContext:));
_origDrawLayerInContext = (void *)method_getImplementation(origMethod);
if(!class_addMethod([mkMapTileView class], @selector(drawLayer:inContext:), (IMP)OverrideDrawLayerInContext, method_getTypeEncoding(origMethod)))
method_setImplementation(origMethod, (IMP)OverrideDrawLayerInContext);
// implement our Override
static void OverrideDrawLayerInContext(UIView *self, SEL _cmd, CALayer *layer, CGContextRef context) {
// possibly call original method if you leave it empty base google maps will not be displayed. You can draw custom content here as well...
// _origDrawLayerInContext(self, _cmd, layer, context);