Skip to content

Instantly share code, notes, and snippets.

@msingleton
Created May 27, 2015 19:57
Show Gist options
  • Save msingleton/f5c6aa12ab761d42fdb7 to your computer and use it in GitHub Desktop.
Save msingleton/f5c6aa12ab761d42fdb7 to your computer and use it in GitHub Desktop.
MGLMapView
class ViewController: UIViewController {
var mapView: MGLMapView?
init() {
super.init(nibName: nil, bundle: nil)
MGLAccountManager.setMapboxMetricsEnabledSettingShownInApp(true)
mapView = MGLMapView(frame: CGRectNull, accessToken: "FOO")
view.addSubview(mapView!)
initConstraints()
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func initConstraints() {
mapView!.setTranslatesAutoresizingMaskIntoConstraints(false)
view.addConstraints([
NSLayoutConstraint(item: mapView!, attribute: .Top, relatedBy: .Equal, toItem: view, attribute: .Top, multiplier: 1, constant: 0),
NSLayoutConstraint(item: mapView!, attribute: .Bottom, relatedBy: .Equal, toItem: view, attribute: .Bottom, multiplier: 1, constant: 0),
NSLayoutConstraint(item: mapView!, attribute: .Leading, relatedBy: .Equal, toItem: view, attribute: .Leading, multiplier: 1, constant: 0),
NSLayoutConstraint(item: mapView!, attribute: .Trailing, relatedBy: .Equal, toItem: view, attribute: .Trailing, multiplier: 1, constant: 0)
])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment