summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-03-05 15:57:28 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-03-08 12:14:22 -0700
commit78900c6eeec08e23efba4c5eafcb6faeefc9e424 (patch)
treef5bb42cbae9648adaf5aee2037a701fe03ee04f8 /platform
parenta5998dc59b0b2ba37b4ff8543d5decb7e37c9cfa (diff)
downloadqtlocation-mapboxgl-78900c6eeec08e23efba4c5eafcb6faeefc9e424.tar.gz
Alias hybrid to satellite
Looks terrible at the moment, but the API is closer to what developers would expect. Fixes #935.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLMapView.mm36
1 files changed, 31 insertions, 5 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 45c96e7c3b..141d6cae1d 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -92,7 +92,9 @@ NSTimeInterval const MGLAnimationDuration = 0.3;
@end
-@implementation MGLMapView
+@implementation MGLMapView {
+ NSMutableArray *_bundledStyleNames;
+}
#pragma mark - Setup & Teardown -
@@ -938,16 +940,40 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
- (NSArray *)bundledStyleNames
{
- NSString *stylesPath = [[MGLMapView resourceBundlePath] stringByAppendingString:@"/styles"];
-
- NSArray *styleNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:stylesPath error:nil];
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ if (!_bundledStyleNames) {
+ NSString *stylesPath = [[MGLMapView resourceBundlePath] stringByAppendingString:@"/styles"];
+
+ _bundledStyleNames = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:stylesPath error:nil] mutableCopy];
+
+ // Add hybrids
+ NSString *hybridStylePrefix = @"hybrid-";
+ NSString *satelliteStylePrefix = @"satellite-";
+ NSMutableArray *hybridStyleNames = [NSMutableArray array];
+ for (NSString *styleName in _bundledStyleNames) {
+ if ([styleName hasPrefix:satelliteStylePrefix]) {
+ [hybridStyleNames addObject:[hybridStylePrefix stringByAppendingString:[styleName substringFromIndex:[satelliteStylePrefix length]]]];
+ }
+ }
+ [_bundledStyleNames addObjectsFromArray:hybridStyleNames];
+ }
+ });
- return styleNames;
+ return _bundledStyleNames;
}
- (void)useBundledStyleNamed:(NSString *)styleName
{
+ NSString *hybridStylePrefix = @"hybrid-";
+ BOOL isHybrid = [styleName hasPrefix:hybridStylePrefix];
+ if (isHybrid) {
+ styleName = [@"satellite-" stringByAppendingString:[styleName substringFromIndex:[hybridStylePrefix length]]];
+ }
[self setStyleURL:[NSString stringWithFormat:@"styles/%@.json", styleName]];
+ if (isHybrid) {
+ [self setAppliedStyleClasses:@[@"contours", @"labels"]];
+ }
}
- (NSArray *)getStyleOrderedLayerNames