summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-04-08 17:29:58 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-04-08 17:29:58 -0700
commit0b35a887085cebc4dac99aac6e870504ae24b8e5 (patch)
tree9e7b6b36456dfa129878c3df07f9bd9a08d926c5 /ios
parentd1be8ed786da405a891ec755828fdea90126da30 (diff)
downloadqtlocation-mapboxgl-0b35a887085cebc4dac99aac6e870504ae24b8e5.tar.gz
Override file name for Mapbox Streets style JSON
Some styles have nonstandard file names that don’t end with “-v7”. This commit adds a special case for Mapbox Streets that can be extended in the future for other styles. Ref #1228
Diffstat (limited to 'ios')
-rw-r--r--ios/app/MBXViewController.mm15
1 files changed, 12 insertions, 3 deletions
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm
index d76ca42a39..f4047c40f6 100644
--- a/ios/app/MBXViewController.mm
+++ b/ios/app/MBXViewController.mm
@@ -20,6 +20,10 @@ static NSArray *const kStyleNames = @[
@"Satellite",
];
+static NSDictionary *const kStyleFileNames = @{
+ @"Mapbox Streets": @"mapbox-streets",
+};
+
static NSString *const kStyleVersion = @"7";
@interface MBXViewController () <UIActionSheetDelegate, MGLMapViewDelegate>
@@ -246,11 +250,16 @@ mbgl::Settings_NSUserDefaults *settings = nullptr;
if (index == [kStyleNames count]) index = 0;
styleName = [kStyleNames objectAtIndex:index];
}
+
+ NSString *styleFileName = kStyleFileNames[styleName];
+ if (!styleFileName) {
+ styleFileName = [NSString stringWithFormat:@"%@-v%@",
+ [styleName.lowercaseString stringByReplacingOccurrencesOfString:@" " withString:@"-"],
+ kStyleVersion];
+ }
self.mapView.styleURL = [NSURL URLWithString:
- [NSString stringWithFormat:@"asset://styles/%@-v%@.json",
- [[styleName lowercaseString] stringByReplacingOccurrencesOfString:@" " withString:@"-"],
- kStyleVersion]];
+ [NSString stringWithFormat:@"asset://styles/%@.json", styleFileName]];
[titleButton setTitle:styleName forState:UIControlStateNormal];
}