[ios, macos] Added URL accessor to MGLTileSource

This commit is contained in:
Minh Nguyễn
2016-12-12 16:04:28 -08:00
committed by Minh Nguyễn
parent 117c8ed1d1
commit 224fe6b96f
4 changed files with 27 additions and 0 deletions

View File

@@ -95,6 +95,11 @@ static const CGFloat MGLRasterSourceRetinaTileSize = 512;
super.rawSource = rawSource;
}
- (NSURL *)configurationURL {
auto url = self.rawSource->getURL();
return url ? [NSURL URLWithString:@(url->c_str())] : nil;
}
- (NSString *)attributionHTMLString {
auto attribution = self.rawSource->getAttribution();
return attribution ? @(attribution->c_str()) : nil;

View File

@@ -162,6 +162,17 @@ typedef NS_ENUM(NSUInteger, MGLTileCoordinateSystem) {
*/
- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_ARRAY_OF(NSString *) *)tileURLTemplates options:(nullable NS_DICTIONARY_OF(MGLTileSourceOption, id) *)options;
#pragma mark Accessing a Source’s Content
/**
The URL to the TileJSON configuration file that specifies the contents of the
source.
If the receiver was initialized using
`-initWithIdentifier:tileURLTemplates:options`, this property is set to `nil`.
*/
@property (nonatomic, copy, nullable, readonly) NSURL *configurationURL;
#pragma mark Accessing Attribution Strings
/**

View File

@@ -27,6 +27,12 @@ const MGLTileSourceOption MGLTileSourceOptionTileCoordinateSystem = @"MGLTileSou
return [super initWithIdentifier:identifier];
}
- (NSURL *)configurationURL {
[NSException raise:@"MGLAbstractClassException"
format:@"MGLTileSource is an abstract class"];
return nil;
}
- (NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfos {
return [self attributionInfosWithFontSize:0 linkColor:nil];
}

View File

@@ -69,6 +69,11 @@
super.rawSource = rawSource;
}
- (NSURL *)configurationURL {
auto url = self.rawSource->getURL();
return url ? [NSURL URLWithString:@(url->c_str())] : nil;
}
- (NSString *)attributionHTMLString {
auto attribution = self.rawSource->getAttribution();
return attribution ? @(attribution->c_str()) : nil;