From 0b35a887085cebc4dac99aac6e870504ae24b8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Wed, 8 Apr 2015 17:29:58 -0700 Subject: Override file name for Mapbox Streets style JSON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- ios/app/MBXViewController.mm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'ios') 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 () @@ -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]; } -- cgit v1.2.1