Только что начал с Mapbox. Я нашел код для Objective-c, но я не знаю, как это сделать в Swift. Есть идеи?Как настроить тему Mapbox
Вот код Objective-C:
#import "Mapbox.h"
@interface ViewController()
@property (nonatomic, strong) RMMapView *mapView;
@end
@implementation MyViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[RMConfiguration sharedInstance] setAccessToken:@"<access token>"];
// Specially this line below
RMMapboxSource *tileSource = [[RMMapboxSource alloc] initWithMapID:@"mapbox.wheatpaste"];
// set coordinates
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(38.910003, -77.015533);
self.mapView = [[RMMapView alloc] initWithFrame:self.view.bounds
andTilesource:tileSource];
[self.view addSubview:self.mapView];
}
@end
Вот мой Swift код
import MapboxGL
class AppViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate {
var mapView: MGLMapView!
override func viewDidLoad() {
mapView = MGLMapView(frame: mapBoxWrapper.bounds, styleURL: NSURL(string:"dark-v7.json"))
mapView = Mapbox.configure(mapView)
// set the map's center coordinate
mapView.setCenterCoordinate(appleMap.userLocation.coordinate,
zoomLevel: 12, animated: true)
mapBoxWrapper.addSubview(mapView)
}
}
Я хочу также использовать карту ID вместо URL. Есть идеи?