Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Added URL accessor to MGLTileSource
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Dec 21, 2016
1 parent ad21135 commit f390b59
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions platform/darwin/src/MGLRasterSource.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions platform/darwin/src/MGLTileSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
6 changes: 6 additions & 0 deletions platform/darwin/src/MGLTileSource.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
5 changes: 5 additions & 0 deletions platform/darwin/src/MGLVectorSource.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f390b59

Please sign in to comment.