diff --git a/platform/darwin/src/MGLRasterSource.mm b/platform/darwin/src/MGLRasterSource.mm index edca8bced19..9f57bb10a3c 100644 --- a/platform/darwin/src/MGLRasterSource.mm +++ b/platform/darwin/src/MGLRasterSource.mm @@ -95,6 +95,11 @@ - (void)setRawSource:(mbgl::style::RasterSource *)rawSource { 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; diff --git a/platform/darwin/src/MGLTileSource.h b/platform/darwin/src/MGLTileSource.h index caf915637ef..994375bec04 100644 --- a/platform/darwin/src/MGLTileSource.h +++ b/platform/darwin/src/MGLTileSource.h @@ -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 /** diff --git a/platform/darwin/src/MGLTileSource.mm b/platform/darwin/src/MGLTileSource.mm index 522675bc884..1aef81d53ca 100644 --- a/platform/darwin/src/MGLTileSource.mm +++ b/platform/darwin/src/MGLTileSource.mm @@ -27,6 +27,12 @@ - (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_A 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]; } diff --git a/platform/darwin/src/MGLVectorSource.mm b/platform/darwin/src/MGLVectorSource.mm index 0eea8dd18c8..3ec54ac0943 100644 --- a/platform/darwin/src/MGLVectorSource.mm +++ b/platform/darwin/src/MGLVectorSource.mm @@ -69,6 +69,11 @@ - (void)setRawSource:(mbgl::style::VectorSource *)rawSource { 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;