diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index aa92b0c82..1fd3b6981 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -33,6 +33,13 @@ * @return An initialized map view, or `nil` if the map view was unable to be initialized. */ - (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken bundledStyleNamed:(NSString *)styleName; +/** Initialize a map view with a given frame, style URL, and access token. +* @param frame The frame with which to initialize the map view. +* @param accessToken A Mapbox API access token. +* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://`). +* @return An initialized map view, or `nil` if the map view was unable to be initialized. */ +- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL; + /** Initialize a map view with a given frame, the default style, and an access token. * @param frame The frame with which to initialize the map view. * @param accessToken A Mapbox API access token. diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 76413bc2c..ec78d432e 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -132,6 +132,19 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; return self; } +- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL +{ + self = [super initWithFrame:frame]; + + if (self && [self commonInit]) + { + if (accessToken) [self setAccessToken:accessToken]; + if (styleURL) [self setStyleURL:[styleURL absoluteString]]; + } + + return self; +} + - (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken { return [self initWithFrame:frame accessToken:accessToken styleJSON:nil];