Merge pull request #1214 from mapbox/1ec5-classes

Expose style class API publicly
This commit is contained in:
Minh Nguyễn
2015-04-06 14:36:10 -07:00
2 changed files with 34 additions and 1 deletions

View File

@@ -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 */

View File

@@ -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