Latest 0.1.0
Homepage https://github.com/jmbiggs/MBMapKitGoogleStyler
License MIT
Platforms ios 8.0
Frameworks UIKit, MapKit
Authors

CI Status
Version
License
Platform

Introduction

NOTE: This is an Objective-C port of MapKitGoogleStyler by fmo91. Use it if you are unable (or unwilling) to use Swift in your project, otherwise you can use the original.

MBMapKitGoogleStyler allows you to include Google Maps JSON styles, that you can create here, and customize your MKMapView to look just like you want (or your client). Including this library is very very easy.

A post explaining the concept in detail (and how to use the Swift version) can be found here: https://medium.com/@ortizfernandomartin/customize-mapkits-mkmapview-with-google-maps-styling-wizard-a5dcc095e19f#.ss3dencgh

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

To easily get styling on an MKMapView:

  1. Create your styling here, and generate a JSON file.

  2. Put the JSON in a plain text file in your project. You can name it whatever you want, in this example I’ll call it ‘MapStyle.json’.

  3. Import MBMapKitGoogleStyler into your view controller

    #import <MBMapKitGoogleStyler/MBMapKitGoogleStyler.h>
  4. Make sure your view controller is a MKMapViewDelegate, and implement -mapViewrendererForOverlay

    Interface declaration:

    @interface MBViewController () <MKMapViewDelegate>

    Set delegate on MKMapView (in -viewDidLoad):

    [_mapView setDelegate:self];

    Implement delegate method:

    - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
    {
    MKTileOverlay * tileOverlay = (MKTileOverlay*)overlay;
    if (tileOverlay) {
        return [[MKTileOverlayRenderer alloc] initWithTileOverlay:tileOverlay];
    } else {
        return [[MKOverlayRenderer alloc] initWithOverlay:overlay];
    }
    }
  5. Write a function to add the tile overlay to your Map View (make sure you import the JSON file as you named it)

    - (void)configureTileOverlay {
    // import the JSON file
    NSString * overlayFileURLString = [[NSBundle mainBundle] pathForResource:@"MapStyle" ofType:@"json"];
    
    NSURL * overlayFileURL = [NSURL fileURLWithPath:overlayFileURLString];
    MKTileOverlay * tileOverlay = [MBMapKitGoogleStyler buildOverlayWithJSONFileURL:overlayFileURL];
    [_mapView addOverlay:tileOverlay];
    }

    Call it after setting the delegate (-viewDidLoad):

    [_mapView setDelegate:self];
    [self configureTileOverlay];

Requirements

  • MapKit

Installation

MBMapKitGoogleStyler is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'MBMapKitGoogleStyler'

Author

jmbiggs, [email protected]
fmo91, [email protected] (original Swift version)

License

MBMapKitGoogleStyler is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MBMapKitGoogleStyler",
    "version": "0.1.0",
    "summary": "Google Map JSON styles in MapKit (Swift not required).",
    "description": "Objective-C port of MapKitGoogleStyler.nBlog post here: https://medium.com/@ortizfernandomartin/customize-mapkits-mkmapview-with-google-maps-styling-wizard-a5dcc095e19f#.zgj20kkvk",
    "homepage": "https://github.com/jmbiggs/MBMapKitGoogleStyler",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "jmbiggs": "[email protected]"
    },
    "source": {
        "git": "https://github.com/jmbiggs/MBMapKitGoogleStyler.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MBMapKitGoogleStyler/Classes/**/*",
    "frameworks": [
        "UIKit",
        "MapKit"
    ]
}

Pin It on Pinterest

Share This