Default styles
To use one of the default styles provided by Mapbox, call the corresponding class method of MGLStyle
, then pass the return value into -[MGLMapView setStyleURL:]
.
If you’re using an Interface Builder storyboard, set the Style URL inspectable to a URL such as mapbox://styles/mapbox/light-v9
.
ViewController
import Mapbox class ViewController: UIViewController {override func viewDidLoad() {super.viewDidLoad() let mapView = MGLMapView(frame: view.bounds, styleURL: MGLStyle.outdoorsStyleURL) // Tint the ℹ️ button and the user location annotation.mapView.tintColor = .darkGray mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight] // Set the map’s center coordinate and zoom level.mapView.setCenter(CLLocationCoordinate2D(latitude: 51.50713, longitude: -0.10957),zoomLevel: 13, animated: false)view.addSubview(mapView)}}