Authored by Justin R. Miller

fixes #566: remove v3 API access

... ... @@ -44,9 +44,7 @@
/** @name Authorizing Access */
/** A Mapbox API access token. Obtain an access token on your [Mapbox account page](https://www.mapbox.com/account/apps/). Setting an access token will use Mapbox's `v4` API; otherwise, `v3` will be used. At a future date, `v3` support will be phased out of this library, and new Mapbox accounts only support `v4`.
*
* @warning Use of the Mapbox `v4` API on retina devices will use `512px` map tile images instead of `256px`, which won't be able to be composited with other tile sources that are not also `512px` in size. */
/** A Mapbox API access token. Obtain an access token on your [Mapbox account page](https://www.mapbox.com/account/apps/). */
@property (nonatomic, retain) NSString *accessToken;
/** @name Cache Configuration */
... ...
... ... @@ -135,6 +135,13 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
return self;
}
- (NSString *)accessToken
{
NSAssert(_accessToken, @"An access token is required in order to use the Mapbox API. Obtain a token on your Mapbox account page at https://www.mapbox.com/account/apps/.");
return _accessToken;
}
- (NSDictionary *)cacheConfiguration
{
if (_propertyList == nil)
... ...
... ... @@ -60,6 +60,8 @@ typedef enum : NSUInteger {
/** @name Creating Tile Sources */
- (id)init DEPRECATED_MSG_ATTRIBUTE("please use an explicit map ID, URL, or TileJSON string.");
/** Initialize a tile source using the Mapbox map ID.
*
* This method requires a network connection in order to download the TileJSON used to define the tile source.
... ...
... ... @@ -53,7 +53,7 @@
- (id)init
{
return [self initWithReferenceURL:[NSURL fileURLWithPath:[RMMapView pathForBundleResourceNamed:kMapboxPlaceholderMapID ofType:@"json"]]];
return [self initWithMapID:kMapboxPlaceholderMapID];
}
- (id)initWithMapID:(NSString *)mapID
... ... @@ -167,10 +167,6 @@
{
return [self initWithTileJSON:dataObject enablingDataOnMapView:mapView];
}
else if ( ! [[RMConfiguration sharedInstance] accessToken])
{
RMLog(@"Unable to create Mapbox tile source and no access token is set! Please go to https://mapbox.com/account/apps/ for a token.");
}
return nil;
}
... ... @@ -192,10 +188,8 @@
- (NSURL *)canonicalURLForMapID:(NSString *)mapID
{
NSString *version = ([[RMConfiguration sharedInstance] accessToken] ? @"v4" : @"v3");
NSString *accessToken = ([[RMConfiguration sharedInstance] accessToken] ? [@"&access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]] : @"");
return [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/%@/%@.json?secure%@", version, mapID, accessToken]];
return [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/v4/%@.json?secure%@", mapID,
[@"&access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]]]];
}
- (NSURL *)tileJSONURL
... ...
... ... @@ -140,17 +140,14 @@
- (id)initWithMapboxMarkerImage:(NSString *)symbolName tintColorHex:(NSString *)colorHex sizeString:(NSString *)sizeString
{
NSString *version = ([[RMConfiguration sharedInstance] accessToken] ? @"v4" : @"v3");
NSString *accessToken = ([[RMConfiguration sharedInstance] accessToken] ? [@"?access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]] : @"");
BOOL useRetina = ([[UIScreen mainScreen] scale] > 1.0);
BOOL useRetina = ([[UIScreen mainScreen] scale] > 1.0);
NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/%@/marker/pin-%@%@%@%@.png%@",
version,
(sizeString ? [sizeString substringToIndex:1] : @"m"),
NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/v4/marker/pin-%@%@%@%@.png%@",
(sizeString ? [sizeString substringToIndex:1] : @"m"),
(symbolName ? [@"-" stringByAppendingString:symbolName] : @""),
(colorHex ? [@"+" stringByAppendingString:[colorHex stringByReplacingOccurrencesOfString:@"#" withString:@""]] : @"+ff0000"),
(useRetina ? @"@2x" : @""),
accessToken]];
[@"?access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]]]];
UIImage *image = nil;
... ...
{"attribution":"<a href='https://mapbox.com/about/maps' target='_blank'>Terms & Feedback</a>","bounds":[-180,-85.0511,180,85.0511],"center":[0,0,3],"description":"","geocoder":"https://a.tiles.mapbox.com/v3/examples.map-z2effxa8/geocode/{query}.jsonp","id":"examples.map-z2effxa8","maxzoom":19,"minzoom":0,"name":"Mapbox iOS Example","private":true,"scheme":"xyz","tilejson":"2.0.0","tiles":["https://a.tiles.mapbox.com/v3/examples.map-z2effxa8/{z}/{x}/{y}.png","https://b.tiles.mapbox.com/v3/examples.map-z2effxa8/{z}/{x}/{y}.png","https://c.tiles.mapbox.com/v3/examples.map-z2effxa8/{z}/{x}/{y}.png","https://d.tiles.mapbox.com/v3/examples.map-z2effxa8/{z}/{x}/{y}.png"],"webpage":"https://tiles.mapbox.com/examples/map/map-z2effxa8"}
\ No newline at end of file
... ... @@ -93,7 +93,6 @@
DD1985C2165C5F6400DF667F /* RMTileMillSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1985C0165C5F6400DF667F /* RMTileMillSource.m */; };
DD1E3C6E161F954F004FC649 /* SMCalloutView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD1E3C6C161F954F004FC649 /* SMCalloutView.h */; };
DD1E3C6F161F954F004FC649 /* SMCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1E3C6D161F954F004FC649 /* SMCalloutView.m */; };
DD280D1416EFDDD30014B549 /* examples.map-z2effxa8.json in Resources */ = {isa = PBXBuildFile; fileRef = DD280D1216EFDDD30014B549 /* examples.map-z2effxa8.json */; };
DD2B375514CF8197008DE8CB /* RMMBTilesSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
DD2B375614CF8197008DE8CB /* RMMBTilesSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */; };
DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DD36766A17D94F980001F27B /* mapbox-logo@2x.png */; };
... ... @@ -277,7 +276,6 @@
DD1985C0165C5F6400DF667F /* RMTileMillSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMTileMillSource.m; sourceTree = "<group>"; };
DD1E3C6C161F954F004FC649 /* SMCalloutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SMCalloutView.h; path = SMCalloutView/SMCalloutView.h; sourceTree = "<group>"; };
DD1E3C6D161F954F004FC649 /* SMCalloutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SMCalloutView.m; path = SMCalloutView/SMCalloutView.m; sourceTree = "<group>"; };
DD280D1216EFDDD30014B549 /* examples.map-z2effxa8.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "examples.map-z2effxa8.json"; path = "Map/Resources/examples.map-z2effxa8.json"; sourceTree = "<group>"; };
DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMBTilesSource.h; sourceTree = "<group>"; };
DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMBTilesSource.m; sourceTree = "<group>"; };
DD36766A17D94F980001F27B /* mapbox-logo@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "mapbox-logo@2x.png"; path = "Map/Resources/mapbox-logo@2x.png"; sourceTree = "<group>"; };
... ... @@ -652,7 +650,6 @@
DD932BC1165C287600D69D49 /* Resources */ = {
isa = PBXGroup;
children = (
DD280D1216EFDDD30014B549 /* examples.map-z2effxa8.json */,
DD932BA5165C287000D69D49 /* mapbox.png */,
DD932BA6165C287000D69D49 /* mapbox@2x.png */,
DDE68E5917D94C0500F1E869 /* mapbox-logo.png */,
... ... @@ -911,7 +908,6 @@
DD07A23D17F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png in Resources */,
DD94D46C16C2E064003D5739 /* HeadingAngleMedium.png in Resources */,
DD94D46D16C2E064003D5739 /* HeadingAngleMedium@2x.png in Resources */,
DD280D1416EFDDD30014B549 /* examples.map-z2effxa8.json in Resources */,
DD07A23B17F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png in Resources */,
DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */,
DDA257021798A95600BBB325 /* TrackingLocationOffMask@2x.png in Resources */,
... ...