From af09fd599a15881eda20232fe4225d3a2d67538b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Mon, 6 Apr 2015 12:26:26 -0700 Subject: Expose style class API publicly Also added some convenience methods to match the underlying C++ API. --- include/mbgl/ios/MGLMapView.h | 12 ++++++++++++ platform/ios/MGLMapView.mm | 23 ++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index 5db1f425d5..f2aef61830 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -181,6 +181,18 @@ IB_DESIGNABLE * To display the default style, set this property to `nil`. */ @property (nonatomic) NSURL *styleURL; +/** Currently active style classes, represented as an array of string identifiers. */ +@property (nonatomic) NSArray *styleClasses; + +/** Returns a Boolean value indicating whether the style class with the given identifier is currently active. */ +- (BOOL)hasStyleClass:(NSString *)styleClass; + +/** Activates the style class with the given identifier. */ +- (void)addStyleClass:(NSString *)styleClass; + +/** Deactivates the style class with the given identifier. */ +- (void)removeStyleClass:(NSString *)styleClass; + #pragma mark - Annotating the Map /** @name Annotating the Map */ diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 741f659ad4..d0e224c051 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1357,7 +1357,7 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng) } } -- (NSArray *)getAppliedStyleClasses +- (NSArray *)styleClasses { NSMutableArray *returnArray = [NSMutableArray array]; @@ -1389,6 +1389,27 @@ CLLocationCoordinate2D latLngToCoordinate(mbgl::LatLng latLng) mbglMap->setClasses(newAppliedClasses); } +- (BOOL)hasStyleClass:(NSString *)styleClass +{ + return styleClass && mbglMap->hasClass([styleClass UTF8String]); +} + +- (void)addStyleClass:(NSString *)styleClass +{ + if (styleClass) + { + mbglMap->addClass([styleClass UTF8String]); + } +} + +- (void)removeStyleClass:(NSString *)styleClass +{ + if (styleClass) + { + mbglMap->removeClass([styleClass UTF8String]); + } +} + #pragma mark - Annotations - - (NSArray *)annotations -- cgit v1.2.1