summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-04-23 18:15:01 -0500
committerBrad Leege <bleege@gmail.com>2015-04-23 18:15:01 -0500
commit7e145780ebbd5d35a74f263c51827ae2a37c4eb8 (patch)
tree65b802c19ce520c2c0b1a1c99ab976ba84cbb23b /platform
parent19b5ef367ead43c9e156807ed86da065b0fd3ba2 (diff)
downloadqtlocation-mapboxgl-7e145780ebbd5d35a74f263c51827ae2a37c4eb8.tar.gz
#1225 - Initial conversion of Mapbox GL app to set access token in AppDelegate and exposing MGLMapView.initWithFrame to support it
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLMapView.mm2
-rw-r--r--platform/ios/MapboxGL.m15
2 files changed, 14 insertions, 3 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 5f5e99b0eb..e48b3d82dc 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -25,6 +25,7 @@
#import "SMCalloutView.h"
#import "MGLMapboxEvents.h"
+#import "MapboxGL.h"
#import <algorithm>
@@ -122,6 +123,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
if (self && [self commonInit])
{
self.styleURL = nil;
+ self.accessToken = [MapboxGL getAccessToken];
return self;
}
diff --git a/platform/ios/MapboxGL.m b/platform/ios/MapboxGL.m
index b1cb44cbc9..97ac8f1d5d 100644
--- a/platform/ios/MapboxGL.m
+++ b/platform/ios/MapboxGL.m
@@ -1,22 +1,24 @@
#import <Foundation/Foundation.h>
#import "MapboxGL.h"
+#import "NSProcessInfo+MGLAdditions.h"
@interface MapboxGL()
+@property (atomic) NSString *accessToken;
+
@end
-@property (atomic) NSString *accessToken;
@implementation MapboxGL
+static MapboxGL *_sharedManager;
// Can be called from any thread. Called implicitly from any
// public class convenience methods.
//
-+ (instancetype) sharedInstanceWithAccessToken:(NSString *)token {
++ (id) sharedInstanceWithAccessToken:(NSString *)token {
static dispatch_once_t onceToken;
- static MapboxGL *_sharedManager;
dispatch_once(&onceToken, ^{
if ( ! NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent) {
void (^setupBlock)() = ^{
@@ -36,4 +38,11 @@
return _sharedManager;
}
++ (NSString *) getAccessToken {
+ if (_sharedManager) {
+ return _sharedManager.accessToken;
+ }
+ return nil;
+}
+
@end \ No newline at end of file