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

Commit

Permalink
[ios, macos] Add description string for MGLStyle class
Browse files Browse the repository at this point in the history
Example: <MGLStyle: 0x60800001e0a0; name = "Mapbox Dark", URL = "mapbox://styles/mapbox/dark-v9">

- Adds an internal `URL` property.
  • Loading branch information
friedbunny committed Oct 11, 2016
1 parent 5d85dbd commit 5f969e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions platform/darwin/src/MGLStyle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

@interface MGLStyle()
@property (nonatomic, weak) MGLMapView *mapView;
@property (readonly, copy, nullable) NSURL *URL;
@end

@implementation MGLStyle
Expand Down Expand Up @@ -92,6 +93,10 @@ - (NSString *)name {
return @(self.mapView.mbglMap->getStyleName().c_str());
}

- (NSURL *)URL {
return [NSURL URLWithString:@(self.mapView.mbglMap->getStyleURL().c_str())];
}

- (MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier
{
auto mbglLayer = self.mapView.mbglMap->getLayer(identifier.UTF8String);
Expand Down Expand Up @@ -254,5 +259,12 @@ - (void)removeStyleClass:(NSString *)styleClass
}
}

- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; name = %@, URL = %@>",
NSStringFromClass([self class]), (void *)self,
self.name ? [NSString stringWithFormat:@"\"%@\"", self.name] : self.name,
self.URL ? [NSString stringWithFormat:@"\"%@\"", self.URL] : self.URL];
}

@end

0 comments on commit 5f969e3

Please sign in to comment.