Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Using Mapbox iOS SDK in an Interface Builder storyboard

Minh Nguyễn edited this page Oct 23, 2015 · 4 revisions
  1. Drag a UIView out from the Object library into a UIViewController in a storyboard.
  2. In the Identity inspector, set the custom class to MGLMapView.
  3. In the Attributes inspector, optionally set a custom style URL (in the form mapbox://styles/STYLE_ID), initial coordinates, and initial zoom level.
  4. (Optional) Set up the MGLMapView’s Auto Layout constraints.
  5. Build and run.

designable

If your app needs to manipulate the map after launch, hook the MGLMapView up to an outlet:

  1. Switch to the Assistant Editor.
  2. Control-drag from the map view in Interface Builder to your view controller’s implementation.
  3. Import Mapbox’s umbrella header into that file.

The resulting outlet declaration should look something like:

// ViewController.m
#import "MapboxGL.h"

@interface ViewController : UIViewController

@property (strong) IBOutlet MGLMapView *mapView;

@end
// ViewController.swift
import MapboxGL

class ViewController: UIViewController {
    @IBOutlet var mapView: MGLMapView!
}
Clone this wiki locally