How to erase iOS6 maps in MapKit

Update: be aware as this is not working on iOS7, however in iOS7 MapKit officially supports to disable base layer !

This blog : https://blog.sumbera.com/2011/09/18/how-to-disable-base-google-maps-in-mapkit/ wrote about how to disable Google maps in MapKit. Now with new iOS6 and brand new Apple maps and OpenGL rendering , the question is how to disable rendering of the base maps without using undocumented functions. Removing whole base layer (VKMapView) is possible but cripples touch handling of the overlays. So here is very simple way how to do this without removing VKMapView – just set opacity of the layer to 0.0. This will erase base iOS6 maps .

+(void) eraseiOS6maps:(UIView*) mapView{
   // -- get rendering layer
    UIView *rootView = [mapView.subviews objectAtIndex:0];
    UIView *vkmapView = [rootView.subviews objectAtIndex:0];
    UIView *vkmapCanvas = [vkmapView.subviews objectAtIndex:0];
   // -- set opacity to 0.0 
    [vkmapCanvas.layer setOpacity:0.0];
}

View hierarchy:

MkMapView/UIView/VKMapView/VKMapCanvas
MkMapView/UIView/MkScrollContainerView/MkOverlayContainerView/MkOverlayClusterView/<your overlay>
MkMapView/UIView/MkAnnotation/...
MkMapView/MkAttributionLabel

4 thoughts on “How to erase iOS6 maps in MapKit

  1. Pingback: How to disable base Google Maps in MapKit « Geospatial Haiku

  2. Billy

    Do you know how to add a Tiled WMS overlay in MapKit? I have wms that update every three hours and would not be able to cache them.

    Reply
  3. noxymoelge

    Hi Stanislav! I am so happy I ‘accidentially’ came here from stackoverflow. I actually saw your solution and boy it works. But i have one suggestion to make it work even better – see also here http://pastebin.com/SkGhVmE8 for code, but i will try to put it directly in the comment here:

    - (UIView*) viewToDeactivateInView:(UIView*)view {
        UIView *viewFound = nil;
        if( view && view.subviews && [view.subviews count] > 0 ) {
            for( UIView *currentView in view.subviews ) {
                NSString *className = NSStringFromClass( [currentView class] );
                if( [className isEqualToString:@"VKMapCanvas"] ) {
                    viewFound = currentView;
                    break;
                }
                else {
                    viewFound = [self viewToDeactivateInView:currentView];
                    if( viewFound ) {
                        break;
                    }
                }
            }
        }
        return viewFound;
    }
    
    - (void) baseMapEnableVisibility:(BOOL)isVisible {
        UIView *targetView = [self viewToDeactivateInView:localMapView];
        if( targetView ) {
            NSLog( @"MAP CANVAS: %@", NSStringFromClass([targetView class]) );
            [targetView.layer setOpacity:(isVisible ? 1.0 : 0.0)];
        }
        else {
            NSLog( @"MAP CANVAS NOT FOUND." );
        }
    }
    

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.