[ios, macos] Add description string for MGLStyle class

Example: <MGLStyle: 0x60800001e0a0; name = "Mapbox Dark", URL = "mapbox://styles/mapbox/dark-v9">

- Adds an internal `URL` property.
This commit is contained in:
Jason Wray
2016-10-07 15:23:47 -04:00
committed by Jason Wray
parent 5d85dbd7cd
commit 5f969e3302

View File

@@ -34,6 +34,7 @@
@interface MGLStyle()
@property (nonatomic, weak) MGLMapView *mapView;
@property (readonly, copy, nullable) NSURL *URL;
@end
@implementation MGLStyle
@@ -92,6 +93,10 @@ static NSURL *MGLStyleURL_emerald;
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);
@@ -254,5 +259,12 @@ static NSURL *MGLStyleURL_emerald;
}
}
- (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