summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-05-20 10:45:26 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-05-20 10:45:26 -0700
commit9a57464f823b36dc0c7b0db75f742a40513ffc87 (patch)
tree52f950a58499014d2557494016aa677b54b724e6 /platform
parenta04703e2d59ccedf32ef9bbd22169640a5aeec50 (diff)
downloadqtlocation-mapboxgl-9a57464f823b36dc0c7b0db75f742a40513ffc87.tar.gz
Removed accessToken from MGLMapView public API
With helpful instructions for migrating to Info.plist or the `MGLAccountManager` API.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLMapView.mm28
1 files changed, 12 insertions, 16 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 4be5d20d27..cb89c58d46 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -113,25 +113,18 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
if (self && [self commonInit])
{
self.styleURL = nil;
- self.accessToken = [MGLAccountManager accessToken];
return self;
}
return nil;
}
-- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken
-{
- return [self initWithFrame:frame accessToken:accessToken styleURL:nil];
-}
-
-- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL
+- (instancetype)initWithFrame:(CGRect)frame styleURL:(NSURL *)styleURL
{
self = [super initWithFrame:frame];
if (self && [self commonInit])
{
- self.accessToken = accessToken;
self.styleURL = styleURL;
}
@@ -153,19 +146,18 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
- (NSString *)accessToken
{
- NSString *accessToken = @(_mbglMap->getAccessToken().c_str()).mgl_stringOrNilIfEmpty;
- return accessToken ? accessToken : [MGLAccountManager accessToken];
+ NSAssert(NO, @"-[MGLMapView accessToken] has been removed. Use +[MGLAccountManager accessToken] or get MGLMapboxAccessToken from the Info.plist.");
+ return nil;
}
- (void)setAccessToken:(NSString *)accessToken
{
- _mbglMap->setAccessToken(accessToken ? (std::string)[accessToken UTF8String] : "");
- [MGLAccountManager setAccessToken:accessToken.mgl_stringOrNilIfEmpty];
+ NSAssert(NO, @"-[MGLMapView setAccessToken:] has been replaced by +[MGLAccountManager setAccessToken:].\n\nIf you previously set this access token in a storyboard inspectable, select the MGLMapView in Interface Builder and delete the “accessToken” entry from the User Defined Runtime Attributes section of the Identity inspector. Then go to the Info.plist file and set MGLMapboxAccessToken to “%@”.", accessToken);
}
+ (NSSet *)keyPathsForValuesAffectingStyleURL
{
- return [NSSet setWithObjects:@"mapID", @"accessToken", nil];
+ return [NSSet setWithObjects:@"mapID", nil];
}
- (NSURL *)styleURL
@@ -274,6 +266,10 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
}
_mbglMap->resize(self.bounds.size.width, self.bounds.size.height, _glView.contentScaleFactor);
+ // mbgl::Map keeps its own copy of the access token.
+ NSString *accessToken = [MGLAccountManager accessToken];
+ _mbglMap->setAccessToken(accessToken ? (std::string)[accessToken UTF8String] : "");
+
// Notify map object when network reachability status changes.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reachabilityChanged:)
@@ -1557,7 +1553,7 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
+ (NSSet *)keyPathsForValuesAffectingMapID
{
- return [NSSet setWithObjects:@"styleURL", @"accessToken", nil];
+ return [NSSet setWithObjects:@"styleURL", nil];
}
- (NSString *)mapID
@@ -2495,7 +2491,7 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
self.layer.borderColor = [UIColor colorWithWhite:184/255. alpha:1].CGColor;
self.layer.borderWidth = 1;
- if (self.accessToken)
+ if ([MGLAccountManager accessToken])
{
self.layer.backgroundColor = [UIColor colorWithRed:59/255.
green:178/255.
@@ -2560,7 +2556,7 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng)
// More explanation
UILabel *explanationLabel2 = [[UILabel alloc] init];
- explanationLabel2.text = @"and enter it into the Access Token field in the Attributes inspector or in an MGLMapboxAccessToken entry in the Info.plist file.";
+ explanationLabel2.text = @"and set it as the value of MGLMapboxAccessToken in the Info.plist file.";
explanationLabel2.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
explanationLabel2.numberOfLines = 0;
explanationLabel2.translatesAutoresizingMaskIntoConstraints = NO;