Authored by Justin R. Miller

fixes #115: add SSL support

... ... @@ -69,6 +69,15 @@ typedef enum : NSUInteger {
* @return An initialized MapBox tile source. */
- (id)initWithMapID:(NSString *)mapID;
/** Initialize a tile source using the MapBox map ID, optionally enabling SSL.
*
* This method requires a network connection in order to download the TileJSON used to define the tile source.
*
* @param mapID The MapBox map ID string, typically in the format `<username>.map-<random characters>`.
* @param enableSSL Whether to use SSL-enabled HTTPS connections for map tiles and other related data. Defaults to `NO`. At some point in the future, this will default to `YES`.
* @return An initialized MapBox tile source. */
- (id)initWithMapID:(NSString *)mapID enablingSSL:(BOOL)enableSSL;
/** Initialize a tile source with either a remote or local TileJSON structure.
*
* Passing a remote URL requires a network connection. If offline functionality is desired, you should cache the TileJSON locally at a prior date, then pass a file path URL to this method.
... ... @@ -93,6 +102,16 @@ typedef enum : NSUInteger {
* @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, optionally enabling SSL.
*
* This method requires a network connection in order to download the TileJSON used to define the tile source.
*
* @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.
* @param enableSSL Whether to use SSL-enabled HTTPS connections for map tiles and other related data. Defaults to `NO`. At some point in the future, this will default to `YES`.
* @return An initialized MapBox tile source. */
- (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView enablingSSL:(BOOL)enableSSL;
/** 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.
... ...
... ... @@ -61,7 +61,12 @@
- (id)initWithMapID:(NSString *)mapID
{
return [self initWithMapID:mapID enablingDataOnMapView:nil];
return [self initWithMapID:mapID enablingSSL:NO];
}
- (id)initWithMapID:(NSString *)mapID enablingSSL:(BOOL)enableSSL
{
return [self initWithMapID:mapID enablingDataOnMapView:nil enablingSSL:enableSSL];
}
- (id)initWithTileJSON:(NSString *)tileJSON
... ... @@ -161,7 +166,12 @@
- (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView
{
NSString *referenceURLString = [NSString stringWithFormat:@"http://a.tiles.mapbox.com/v3/%@.json", mapID];
return [self initWithMapID:mapID enablingDataOnMapView:mapView enablingSSL:NO];
}
- (id)initWithMapID:(NSString *)mapID enablingDataOnMapView:(RMMapView *)mapView enablingSSL:(BOOL)enableSSL
{
NSString *referenceURLString = [NSString stringWithFormat:@"http%@://api.tiles.mapbox.com/v3/%@.json%@", (enableSSL ? @"s" : @""), mapID, (enableSSL ? @"?secure" : @"")];
return [self initWithReferenceURL:[NSURL URLWithString:referenceURLString] enablingDataOnMapView:mapView];
}
... ... @@ -175,7 +185,9 @@
- (NSURL *)tileJSONURL
{
return [NSURL URLWithString:[NSString stringWithFormat:@"http://a.tiles.mapbox.com/v3/%@.json", [self.infoDictionary objectForKey:@"id"]]];
BOOL useSSL = [[[self.infoDictionary objectForKey:@"tiles"] objectAtIndex:0] hasPrefix:@"https"];
return [NSURL URLWithString:[NSString stringWithFormat:@"http%@://api.tiles.mapbox.com/v3/%@.json%@", (useSSL ? @"s" : @""), [self.infoDictionary objectForKey:@"id"], (useSSL ? @"?secure" : @"")]];
}
- (NSURL *)URLForTile:(RMTile)tile
... ...