Display Maps (iOS)

This article describes how to display maps using the iOS SDK.

Display Maps

MRMapViewController includes a self-contained interface for maps and directions. This makes it unnecessary for you to create your own maps interface. Initialize MRMapViewController with a valid MREditorKey to get started.

    MREditorKey *mapKey = [MREditorKey keyForMap:@"5638404075159552" app:@"5468665088573440"]; // Meridian Portland Office
    MRMapViewController *mapController = [MRMapViewController new];
    mapController.mapView.mapKey = mapKey;

MRMapViewController hosts an MRMapView and adopts the MRMapViewDelegate protocol, which handles the basic tasks delegated by MRMapView.

You can also use MRMapView directly in your own view controller, optionally implementing methods defined by the MRMapViewDelegate protocol so that your controller can respond to MRMapView events.

You can specify which map to display by setting the mapKey property of the view. Otherwise, the map marked as default in the Meridian Editor will be loaded.

    // In your view controller's `viewDidLoad` method

    MREditorKey *appKey = [MREditorKey keyWithIdentifier:@"5085468668573440"];
    MRMapView *mapView = [[MRMapView alloc] initWithFrame:self.view.bounds];

    // If you want to handle map view events
    mapView.delegate = self;

    // If you want to load a map other than the default one
    mapView.mapKey = [MREditorKey keyForMap:@"5708115733494264" app:appKey.identifier];

    [self.view addSubview:mapView];