From ec194bfacb3b8bca7a2b297e26c31c386452ea55 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Fri, 2 Nov 2012 17:33:48 -0700 Subject: [PATCH] fixes #103: add support for init with MapBox map ID --- MapView/Map/RMMapBoxSource.h | 25 ++++++++++++++++++------- MapView/Map/RMMapBoxSource.m | 12 ++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/MapView/Map/RMMapBoxSource.h b/MapView/Map/RMMapBoxSource.h index 3a17c38d3..ca825c4cb 100644 --- a/MapView/Map/RMMapBoxSource.h +++ b/MapView/Map/RMMapBoxSource.h @@ -53,12 +53,17 @@ typedef enum : NSUInteger { @class RMMapView; -/** 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. */ +/** 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. */ @interface RMMapBoxSource : RMAbstractWebMapSource /** @name Creating Tile Sources */ -/** Designated initializer. Point to either a remote or local TileJSON structure. +/** Initialize a tile source using the MapBox map ID. +* @param mapID The MapBox map ID string, typically in the format `.map-`. +* @return An initialized MapBox tile source. */ +- (id)initWithMapID:(NSString *)mapID; + +/** Initialize a tile source with either a remote or local TileJSON structure. * @param referenceURL A remote or local URL pointing to a TileJSON structure. * @return An initialized MapBox tile source. */ - (id)initWithReferenceURL:(NSURL *)referenceURL; @@ -68,16 +73,22 @@ typedef enum : NSUInteger { * @return An initialized MapBox tile source. */ - (id)initWithTileJSON:(NSString *)tileJSON; -/** For TileJSON 2.1.0+ layers, automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. +* @param mapID The MapBox map ID string, typically in the format `.map-`. +* @param mapView A map view on which to display the annotations. +* @return An initialized MapBox tile source. */ +- (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView; + +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. * @param tileJSON A string containing TileJSON. * @param mapView A map view on which to display the annotations. * @return An initialized MapBox tile source. */ - (id)initWithTileJSON:(NSString *)tileJSON enablingDataOnMapView:(RMMapView *)mapView; -/** For TileJSON 2.1.0+ layers, automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. - * @param referenceURL A remote or local URL pointing to a TileJSON structure. - * @param mapView A map view on which to display the annotations. - * @return An initialized MapBox tile source. */ +/** For TileJSON 2.1.0+ layers, initialize a tile source and automatically find and add annotations from [simplestyle](http://mapbox.com/developers/simplestyle/) data. +* @param referenceURL A remote or local URL pointing to a TileJSON structure. +* @param mapView A map view on which to display the annotations. +* @return An initialized MapBox tile source. */ - (id)initWithReferenceURL:(NSURL *)referenceURL enablingDataOnMapView:(RMMapView *)mapView; /** @name Querying Tile Source Information */ diff --git a/MapView/Map/RMMapBoxSource.m b/MapView/Map/RMMapBoxSource.m index 523d6e773..0ec29fc2c 100644 --- a/MapView/Map/RMMapBoxSource.m +++ b/MapView/Map/RMMapBoxSource.m @@ -50,6 +50,11 @@ @implementation RMMapBoxSource @synthesize infoDictionary=_infoDictionary, imageQuality=_imageQuality; +- (id)initWithMapID:(NSString *)mapID +{ + return [self initWithMapID:mapID enablingDataOnMapView:nil]; +} + - (id)initWithTileJSON:(NSString *)tileJSON { return [self initWithTileJSON:tileJSON enablingDataOnMapView:nil]; @@ -161,6 +166,13 @@ - (id)initWithReferenceURL:(NSURL *)referenceURL enablingDataOnMapView:(RMMapVie return nil; } +- (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView +{ + NSString *referenceURLString = [NSString stringWithFormat:@"http://a.tiles.mapbox.com/v3/%@.jsonp", mapID]; + + return [self initWithReferenceURL:[NSURL URLWithString:referenceURLString] enablingDataOnMapView:mapView]; +} + - (void)dealloc { [_infoDictionary release];