Authored by Justin R. Miller

fixes #103: add support for init with MapBox map ID

@@ -53,12 +53,17 @@ typedef enum : NSUInteger { @@ -53,12 +53,17 @@ typedef enum : NSUInteger {
53 53
54 @class RMMapView; 54 @class RMMapView;
55 55
56 -/** An RMMapBoxSource is used to display map tiles from a network-based map hosted on [MapBox](http://mapbox.com/plans) or the open source [TileStream](https://github.com/mapbox/tilestream) software. Maps are reference by their [TileJSON](http://mapbox.com/developers/tilejson/) endpoint or file. */ 56 +/** An RMMapBoxSource is used to display map tiles from a network-based map hosted on [MapBox](http://mapbox.com/plans) or the open source [TileStream](https://github.com/mapbox/tilestream) software. Maps are reference by their [TileJSON endpoint or MapBox ID](http://mapbox.com/developers/tilejson/) or by a file containing TileJSON. */
57 @interface RMMapBoxSource : RMAbstractWebMapSource 57 @interface RMMapBoxSource : RMAbstractWebMapSource
58 58
59 /** @name Creating Tile Sources */ 59 /** @name Creating Tile Sources */
60 60
61 -/** Designated initializer. Point to either a remote or local TileJSON structure. 61 +/** Initialize a tile source using the MapBox map ID.
  62 +* @param mapID The MapBox map ID string, typically in the format `<username>.map-<random characters>`.
  63 +* @return An initialized MapBox tile source. */
  64 +- (id)initWithMapID:(NSString *)mapID;
  65 +
  66 +/** Initialize a tile source with either a remote or local TileJSON structure.
62 * @param referenceURL A remote or local URL pointing to a TileJSON structure. 67 * @param referenceURL A remote or local URL pointing to a TileJSON structure.
63 * @return An initialized MapBox tile source. */ 68 * @return An initialized MapBox tile source. */
64 - (id)initWithReferenceURL:(NSURL *)referenceURL; 69 - (id)initWithReferenceURL:(NSURL *)referenceURL;
@@ -68,16 +73,22 @@ typedef enum : NSUInteger { @@ -68,16 +73,22 @@ typedef enum : NSUInteger {
68 * @return An initialized MapBox tile source. */ 73 * @return An initialized MapBox tile source. */
69 - (id)initWithTileJSON:(NSString *)tileJSON; 74 - (id)initWithTileJSON:(NSString *)tileJSON;
70 75
71 -/** For TileJSON 2.1.0+ layers, automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. 76 +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data.
  77 +* @param mapID The MapBox map ID string, typically in the format `<username>.map-<random characters>`.
  78 +* @param mapView A map view on which to display the annotations.
  79 +* @return An initialized MapBox tile source. */
  80 +- (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView;
  81 +
  82 +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data.
72 * @param tileJSON A string containing TileJSON. 83 * @param tileJSON A string containing TileJSON.
73 * @param mapView A map view on which to display the annotations. 84 * @param mapView A map view on which to display the annotations.
74 * @return An initialized MapBox tile source. */ 85 * @return An initialized MapBox tile source. */
75 - (id)initWithTileJSON:(NSString *)tileJSON enablingDataOnMapView:(RMMapView *)mapView; 86 - (id)initWithTileJSON:(NSString *)tileJSON enablingDataOnMapView:(RMMapView *)mapView;
76 87
77 -/** For TileJSON 2.1.0+ layers, automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data.  
78 - * @param referenceURL A remote or local URL pointing to a TileJSON structure.  
79 - * @param mapView A map view on which to display the annotations.  
80 - * @return An initialized MapBox tile source. */ 88 +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data.
  89 +* @param referenceURL A remote or local URL pointing to a TileJSON structure.
  90 +* @param mapView A map view on which to display the annotations.
  91 +* @return An initialized MapBox tile source. */
81 - (id)initWithReferenceURL:(NSURL *)referenceURL enablingDataOnMapView:(RMMapView *)mapView; 92 - (id)initWithReferenceURL:(NSURL *)referenceURL enablingDataOnMapView:(RMMapView *)mapView;
82 93
83 /** @name Querying Tile Source Information */ 94 /** @name Querying Tile Source Information */
@@ -50,6 +50,11 @@ @@ -50,6 +50,11 @@
50 50
51 @synthesize infoDictionary=_infoDictionary, imageQuality=_imageQuality; 51 @synthesize infoDictionary=_infoDictionary, imageQuality=_imageQuality;
52 52
  53 +- (id)initWithMapID:(NSString *)mapID
  54 +{
  55 + return [self initWithMapID:mapID enablingDataOnMapView:nil];
  56 +}
  57 +
53 - (id)initWithTileJSON:(NSString *)tileJSON 58 - (id)initWithTileJSON:(NSString *)tileJSON
54 { 59 {
55 return [self initWithTileJSON:tileJSON enablingDataOnMapView:nil]; 60 return [self initWithTileJSON:tileJSON enablingDataOnMapView:nil];
@@ -161,6 +166,13 @@ @@ -161,6 +166,13 @@
161 return nil; 166 return nil;
162 } 167 }
163 168
  169 +- (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView
  170 +{
  171 + NSString *referenceURLString = [NSString stringWithFormat:@"http://a.tiles.mapbox.com/v3/%@.jsonp", mapID];
  172 +
  173 + return [self initWithReferenceURL:[NSURL URLWithString:referenceURLString] enablingDataOnMapView:mapView];
  174 +}
  175 +
164 - (void)dealloc 176 - (void)dealloc
165 { 177 {
166 [_infoDictionary release]; 178 [_infoDictionary release];