summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-03-19 13:39:05 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-03-19 13:39:05 -0700
commit0cdf21c62d1f4ed8f54bd63b3f26459ef78a78d0 (patch)
tree62eecf6de92465867e4b463f5a7dd6d9cdb39684
parentb4dbba93f868b4d44d0f858a9c54924b910ef62d (diff)
parent3d195b467af2901d0c1a5f2103563dc0a2108c35 (diff)
downloadqtlocation-mapboxgl-0cdf21c62d1f4ed8f54bd63b3f26459ef78a78d0.tar.gz
Merge pull request #1020 from mapbox/init-bundled-style
API for initializing with bundled style
-rw-r--r--include/mbgl/ios/MGLMapView.h9
-rw-r--r--platform/ios/MGLMapView.mm17
2 files changed, 23 insertions, 3 deletions
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index f954340262..481e878edc 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -16,10 +16,17 @@
/** Initialize a map view with a given frame, style, and access token.
* @param frame The frame with which to initialize the map view.
+* @param accessToken A Mapbox API access token.
* @param styleJSON The map stylesheet as JSON text.
+* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
+- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleJSON:(NSString *)styleJSON;
+
+/** Initialize a map view with a given frame, bundled style name, and access token.
+* @param frame The frame with which to initialize the map view.
* @param accessToken A Mapbox API access token.
+* @param styleName The map style name to use.
* @return An initialized map view, or `nil` if the map view was unable to be initialized. */
-- (instancetype)initWithFrame:(CGRect)frame styleJSON:(NSString *)styleJSON accessToken:(NSString *)accessToken;
+- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken bundledStyleNamed:(NSString *)styleName;
/** 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.
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 0d530ca1cf..281755a4c8 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -113,7 +113,7 @@ MBGLView *mbglView = nullptr;
mbgl::SQLiteCache *mbglFileCache = nullptr;
mbgl::DefaultFileSource *mbglFileSource = nullptr;
-- (instancetype)initWithFrame:(CGRect)frame styleJSON:(NSString *)styleJSON accessToken:(NSString *)accessToken
+- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleJSON:(NSString *)styleJSON
{
self = [super initWithFrame:frame];
@@ -133,9 +133,22 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
return self;
}
+- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken bundledStyleNamed:(NSString *)styleName
+{
+ self = [super initWithFrame:frame];
+
+ if (self && [self commonInit])
+ {
+ if (accessToken) [self setAccessToken:accessToken];
+ if (styleName) [self useBundledStyleNamed:styleName];
+ }
+
+ return self;
+}
+
- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken
{
- return [self initWithFrame:frame styleJSON:nil accessToken:accessToken];
+ return [self initWithFrame:frame accessToken:accessToken styleJSON:nil];
}
- (instancetype)initWithCoder:(NSCoder *)decoder