Authored by Justin R. Miller

fixes #566: remove v3 API access

@@ -44,9 +44,7 @@ @@ -44,9 +44,7 @@
44 44
45 /** @name Authorizing Access */ 45 /** @name Authorizing Access */
46 46
47 -/** 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`.  
48 -*  
49 -* @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. */ 47 +/** A Mapbox API access token. Obtain an access token on your [Mapbox account page](https://www.mapbox.com/account/apps/). */
50 @property (nonatomic, retain) NSString *accessToken; 48 @property (nonatomic, retain) NSString *accessToken;
51 49
52 /** @name Cache Configuration */ 50 /** @name Cache Configuration */
@@ -135,6 +135,13 @@ static RMConfiguration *RMConfigurationSharedInstance = nil; @@ -135,6 +135,13 @@ static RMConfiguration *RMConfigurationSharedInstance = nil;
135 return self; 135 return self;
136 } 136 }
137 137
  138 +- (NSString *)accessToken
  139 +{
  140 + 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/.");
  141 +
  142 + return _accessToken;
  143 +}
  144 +
138 - (NSDictionary *)cacheConfiguration 145 - (NSDictionary *)cacheConfiguration
139 { 146 {
140 if (_propertyList == nil) 147 if (_propertyList == nil)
@@ -60,6 +60,8 @@ typedef enum : NSUInteger { @@ -60,6 +60,8 @@ typedef enum : NSUInteger {
60 60
61 /** @name Creating Tile Sources */ 61 /** @name Creating Tile Sources */
62 62
  63 +- (id)init DEPRECATED_MSG_ATTRIBUTE("please use an explicit map ID, URL, or TileJSON string.");
  64 +
63 /** Initialize a tile source using the Mapbox map ID. 65 /** Initialize a tile source using the Mapbox map ID.
64 * 66 *
65 * This method requires a network connection in order to download the TileJSON used to define the tile source. 67 * This method requires a network connection in order to download the TileJSON used to define the tile source.
@@ -53,7 +53,7 @@ @@ -53,7 +53,7 @@
53 53
54 - (id)init 54 - (id)init
55 { 55 {
56 - return [self initWithReferenceURL:[NSURL fileURLWithPath:[RMMapView pathForBundleResourceNamed:kMapboxPlaceholderMapID ofType:@"json"]]]; 56 + return [self initWithMapID:kMapboxPlaceholderMapID];
57 } 57 }
58 58
59 - (id)initWithMapID:(NSString *)mapID 59 - (id)initWithMapID:(NSString *)mapID
@@ -167,10 +167,6 @@ @@ -167,10 +167,6 @@
167 { 167 {
168 return [self initWithTileJSON:dataObject enablingDataOnMapView:mapView]; 168 return [self initWithTileJSON:dataObject enablingDataOnMapView:mapView];
169 } 169 }
170 - else if ( ! [[RMConfiguration sharedInstance] accessToken])  
171 - {  
172 - RMLog(@"Unable to create Mapbox tile source and no access token is set! Please go to https://mapbox.com/account/apps/ for a token.");  
173 - }  
174 170
175 return nil; 171 return nil;
176 } 172 }
@@ -192,10 +188,8 @@ @@ -192,10 +188,8 @@
192 188
193 - (NSURL *)canonicalURLForMapID:(NSString *)mapID 189 - (NSURL *)canonicalURLForMapID:(NSString *)mapID
194 { 190 {
195 - NSString *version = ([[RMConfiguration sharedInstance] accessToken] ? @"v4" : @"v3");  
196 - NSString *accessToken = ([[RMConfiguration sharedInstance] accessToken] ? [@"&access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]] : @"");  
197 -  
198 - return [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/%@/%@.json?secure%@", version, mapID, accessToken]]; 191 + return [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/v4/%@.json?secure%@", mapID,
  192 + [@"&access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]]]];
199 } 193 }
200 194
201 - (NSURL *)tileJSONURL 195 - (NSURL *)tileJSONURL
@@ -140,17 +140,14 @@ @@ -140,17 +140,14 @@
140 140
141 - (id)initWithMapboxMarkerImage:(NSString *)symbolName tintColorHex:(NSString *)colorHex sizeString:(NSString *)sizeString 141 - (id)initWithMapboxMarkerImage:(NSString *)symbolName tintColorHex:(NSString *)colorHex sizeString:(NSString *)sizeString
142 { 142 {
143 - NSString *version = ([[RMConfiguration sharedInstance] accessToken] ? @"v4" : @"v3");  
144 - NSString *accessToken = ([[RMConfiguration sharedInstance] accessToken] ? [@"?access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]] : @"");  
145 BOOL useRetina = ([[UIScreen mainScreen] scale] > 1.0); 143 BOOL useRetina = ([[UIScreen mainScreen] scale] > 1.0);
146 144
147 - NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/%@/marker/pin-%@%@%@%@.png%@",  
148 - version, 145 + NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://api.tiles.mapbox.com/v4/marker/pin-%@%@%@%@.png%@",
149 (sizeString ? [sizeString substringToIndex:1] : @"m"), 146 (sizeString ? [sizeString substringToIndex:1] : @"m"),
150 (symbolName ? [@"-" stringByAppendingString:symbolName] : @""), 147 (symbolName ? [@"-" stringByAppendingString:symbolName] : @""),
151 (colorHex ? [@"+" stringByAppendingString:[colorHex stringByReplacingOccurrencesOfString:@"#" withString:@""]] : @"+ff0000"), 148 (colorHex ? [@"+" stringByAppendingString:[colorHex stringByReplacingOccurrencesOfString:@"#" withString:@""]] : @"+ff0000"),
152 (useRetina ? @"@2x" : @""), 149 (useRetina ? @"@2x" : @""),
153 - accessToken]]; 150 + [@"?access_token=" stringByAppendingString:[[RMConfiguration sharedInstance] accessToken]]]];
154 151
155 UIImage *image = nil; 152 UIImage *image = nil;
156 153
1 -{"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"}  
@@ -93,7 +93,6 @@ @@ -93,7 +93,6 @@
93 DD1985C2165C5F6400DF667F /* RMTileMillSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1985C0165C5F6400DF667F /* RMTileMillSource.m */; }; 93 DD1985C2165C5F6400DF667F /* RMTileMillSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1985C0165C5F6400DF667F /* RMTileMillSource.m */; };
94 DD1E3C6E161F954F004FC649 /* SMCalloutView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD1E3C6C161F954F004FC649 /* SMCalloutView.h */; }; 94 DD1E3C6E161F954F004FC649 /* SMCalloutView.h in Headers */ = {isa = PBXBuildFile; fileRef = DD1E3C6C161F954F004FC649 /* SMCalloutView.h */; };
95 DD1E3C6F161F954F004FC649 /* SMCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1E3C6D161F954F004FC649 /* SMCalloutView.m */; }; 95 DD1E3C6F161F954F004FC649 /* SMCalloutView.m in Sources */ = {isa = PBXBuildFile; fileRef = DD1E3C6D161F954F004FC649 /* SMCalloutView.m */; };
96 - DD280D1416EFDDD30014B549 /* examples.map-z2effxa8.json in Resources */ = {isa = PBXBuildFile; fileRef = DD280D1216EFDDD30014B549 /* examples.map-z2effxa8.json */; };  
97 DD2B375514CF8197008DE8CB /* RMMBTilesSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 96 DD2B375514CF8197008DE8CB /* RMMBTilesSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
98 DD2B375614CF8197008DE8CB /* RMMBTilesSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */; }; 97 DD2B375614CF8197008DE8CB /* RMMBTilesSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */; };
99 DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DD36766A17D94F980001F27B /* mapbox-logo@2x.png */; }; 98 DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DD36766A17D94F980001F27B /* mapbox-logo@2x.png */; };
@@ -277,7 +276,6 @@ @@ -277,7 +276,6 @@
277 DD1985C0165C5F6400DF667F /* RMTileMillSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMTileMillSource.m; sourceTree = "<group>"; }; 276 DD1985C0165C5F6400DF667F /* RMTileMillSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMTileMillSource.m; sourceTree = "<group>"; };
278 DD1E3C6C161F954F004FC649 /* SMCalloutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SMCalloutView.h; path = SMCalloutView/SMCalloutView.h; sourceTree = "<group>"; }; 277 DD1E3C6C161F954F004FC649 /* SMCalloutView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SMCalloutView.h; path = SMCalloutView/SMCalloutView.h; sourceTree = "<group>"; };
279 DD1E3C6D161F954F004FC649 /* SMCalloutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SMCalloutView.m; path = SMCalloutView/SMCalloutView.m; sourceTree = "<group>"; }; 278 DD1E3C6D161F954F004FC649 /* SMCalloutView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SMCalloutView.m; path = SMCalloutView/SMCalloutView.m; sourceTree = "<group>"; };
280 - 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>"; };  
281 DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMBTilesSource.h; sourceTree = "<group>"; }; 279 DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMBTilesSource.h; sourceTree = "<group>"; };
282 DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMBTilesSource.m; sourceTree = "<group>"; }; 280 DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMBTilesSource.m; sourceTree = "<group>"; };
283 DD36766A17D94F980001F27B /* mapbox-logo@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "mapbox-logo@2x.png"; path = "Map/Resources/mapbox-logo@2x.png"; sourceTree = "<group>"; }; 281 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 @@ @@ -652,7 +650,6 @@
652 DD932BC1165C287600D69D49 /* Resources */ = { 650 DD932BC1165C287600D69D49 /* Resources */ = {
653 isa = PBXGroup; 651 isa = PBXGroup;
654 children = ( 652 children = (
655 - DD280D1216EFDDD30014B549 /* examples.map-z2effxa8.json */,  
656 DD932BA5165C287000D69D49 /* mapbox.png */, 653 DD932BA5165C287000D69D49 /* mapbox.png */,
657 DD932BA6165C287000D69D49 /* mapbox@2x.png */, 654 DD932BA6165C287000D69D49 /* mapbox@2x.png */,
658 DDE68E5917D94C0500F1E869 /* mapbox-logo.png */, 655 DDE68E5917D94C0500F1E869 /* mapbox-logo.png */,
@@ -911,7 +908,6 @@ @@ -911,7 +908,6 @@
911 DD07A23D17F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png in Resources */, 908 DD07A23D17F3AF9800E420B2 /* HeadingAngleMaskLarge@2x.png in Resources */,
912 DD94D46C16C2E064003D5739 /* HeadingAngleMedium.png in Resources */, 909 DD94D46C16C2E064003D5739 /* HeadingAngleMedium.png in Resources */,
913 DD94D46D16C2E064003D5739 /* HeadingAngleMedium@2x.png in Resources */, 910 DD94D46D16C2E064003D5739 /* HeadingAngleMedium@2x.png in Resources */,
914 - DD280D1416EFDDD30014B549 /* examples.map-z2effxa8.json in Resources */,  
915 DD07A23B17F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png in Resources */, 911 DD07A23B17F3AF9800E420B2 /* HeadingAngleMaskSmall@2x.png in Resources */,
916 DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */, 912 DD36766B17D94F980001F27B /* mapbox-logo@2x.png in Resources */,
917 DDA257021798A95600BBB325 /* TrackingLocationOffMask@2x.png in Resources */, 913 DDA257021798A95600BBB325 /* TrackingLocationOffMask@2x.png in Resources */,