Skip to content

Commit

Permalink
fixes Outdooractive#103: add support for init with MapBox map ID
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Nov 3, 2012
1 parent d49a091 commit ec194bf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
25 changes: 18 additions & 7 deletions MapView/Map/RMMapBoxSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<username>.map-<random characters>`.
* @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;
Expand All @@ -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 `<username>.map-<random characters>`.
* @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 */
Expand Down
12 changes: 12 additions & 0 deletions MapView/Map/RMMapBoxSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit ec194bf

Please sign in to comment.