diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2017-09-05 15:59:56 -0400 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2017-09-15 14:02:30 -0400 |
commit | 2a781e77a18dabc4cf2fa35f28811d1043c9bb2d (patch) | |
tree | b1413a81f4bd2189804577fe7c1cd3e3fe2ea1fc | |
parent | a6224abc33f599f0352682c411b3831b896fb97c (diff) | |
download | qtlocation-mapboxgl-2a781e77a18dabc4cf2fa35f28811d1043c9bb2d.tar.gz |
[ios, macos] Deprecate trafficDayStyleURL and trafficNightStyleURL
-rw-r--r-- | platform/darwin/src/MGLStyle.h | 46 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 33 | ||||
-rw-r--r-- | platform/default/mbgl/util/default_styles.hpp | 3 | ||||
-rw-r--r-- | platform/ios/app/MBXViewController.m | 5 | ||||
-rw-r--r-- | platform/macos/app/MapDocument.m | 14 |
5 files changed, 42 insertions, 59 deletions
diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 8c009d22c6..4bf1f6a4dc 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -270,66 +270,38 @@ MGL_EXPORT + (NSURL *)satelliteStreetsStyleURLWithVersion:(NSInteger)version; /** - Returns the URL to the current version of the + Returns the URL to version 2 of the <a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Day</a> style. - Traffic Day color-codes roads based on live traffic congestion data. Traffic - data is currently available in - <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>. - - @warning The return value may change in a future release of the SDK. If you use - any feature that depends on a specific aspect of a default style – for - instance, the minimum zoom level that includes roads – use the - `-trafficDayStyleURLWithVersion:` method instead. Such details may change - significantly from version to version. */ -+ (NSURL *)trafficDayStyleURL; ++ (NSURL *)trafficDayStyleURL __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-day-v2”."))); /** Returns the URL to the given version of the <a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Day</a> style as of publication. - - Traffic Day color-codes roads based on live traffic congestion data. Traffic - data is currently available in - <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>. - + @param version A specific version of the style. */ -+ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version; ++ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-day-v2”.")));; /** - Returns the URL to the current version of the + Returns the URL to the version 2 of the <a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Night</a> style. - Traffic Night color-codes roads based on live traffic congestion data and is - designed to maximize legibility in low-light situations. Traffic data is - currently available in - <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>. - - @warning The return value may change in a future release of the SDK. If you use - any feature that depends on a specific aspect of a default style – for - instance, the minimum zoom level that includes roads – use the - `-trafficNightStyleURLWithVersion:` method instead. Such details may change - significantly from version to version. */ -+ (NSURL *)trafficNightStyleURL; ++ (NSURL *)trafficNightStyleURL __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-night-v2”."))); /** - Returns the URL to the given version of the + Returns the URL to to the version 2 of the <a href="https://www.mapbox.com/blog/live-traffic-maps/">Mapbox Traffic Night</a> style as of publication. - - Traffic Night color-codes roads based on live traffic congestion data and is - designed to maximize legibility in low-light situations. Traffic data is - currently available in - <a href="https://www.mapbox.com/api-documentation/pages/traffic-countries.html">these select countries</a>. - + @param version A specific version of the style. */ -+ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version; ++ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version __attribute__((deprecated("Create an NSURL object with the string “mapbox://styles/mapbox/traffic-night-v2”."))); #pragma mark Accessing Metadata About the Style diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index d8aa014341..155d983925 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -106,12 +106,10 @@ MGL_DEFINE_STYLE(light, light) MGL_DEFINE_STYLE(dark, dark) MGL_DEFINE_STYLE(satellite, satellite) MGL_DEFINE_STYLE(satelliteStreets, satellite-streets) -MGL_DEFINE_STYLE(trafficDay, traffic-day) -MGL_DEFINE_STYLE(trafficNight, traffic-night) // Make sure all the styles listed in mbgl::util::default_styles::orderedStyles // are defined above and also declared in MGLStyle.h. -static_assert(8 == mbgl::util::default_styles::numOrderedStyles, +static_assert(6 == mbgl::util::default_styles::numOrderedStyles, "mbgl::util::default_styles::orderedStyles and MGLStyle have different numbers of styles."); // Hybrid has been renamed Satellite Streets, so the last Hybrid version is hard-coded here. @@ -134,6 +132,35 @@ static NSURL *MGLStyleURL_emerald; return MGLStyleURL_emerald; } +// Traffic Day is no longer getting new versions as a default style, so the current version is hard-coded here. +static NSURL *MGLStyleURL_trafficDay; ++ (NSURL *)trafficDayStyleURL { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + MGLStyleURL_trafficDay = [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"]; + }); + return MGLStyleURL_trafficDay; +} + ++ (NSURL *)trafficDayStyleURLWithVersion:(NSInteger)version { + return [MGLStyle trafficDayStyleURL]; +} + +// Traffic Night is no longer getting new versions as a default style, so the current version is hard-coded here. +static NSURL *MGLStyleURL_trafficNight; ++ (NSURL *)trafficNightStyleURL { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + MGLStyleURL_trafficNight = [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-night-v2"]; + }); + return MGLStyleURL_trafficNight; +} + ++ (NSURL *)trafficNightStyleURLWithVersion:(NSInteger)version { + return [MGLStyle trafficNightStyleURL]; +} + + #pragma mark - - (instancetype)initWithMapView:(MGLMapView *)mapView { diff --git a/platform/default/mbgl/util/default_styles.hpp b/platform/default/mbgl/util/default_styles.hpp index 43dafb8083..13f08252a7 100644 --- a/platform/default/mbgl/util/default_styles.hpp +++ b/platform/default/mbgl/util/default_styles.hpp @@ -19,12 +19,9 @@ constexpr const DefaultStyle light = { "mapbox://styles/mapbox/light- constexpr const DefaultStyle dark = { "mapbox://styles/mapbox/dark-v9", "Dark", 9 }; constexpr const DefaultStyle satellite = { "mapbox://styles/mapbox/satellite-v9", "Satellite", 9 }; constexpr const DefaultStyle satelliteStreets = { "mapbox://styles/mapbox/satellite-streets-v10", "Satellite Streets", 10 }; -constexpr const DefaultStyle trafficDay = { "mapbox://styles/mapbox/traffic-day-v2", "Traffic Day", 2 }; -constexpr const DefaultStyle trafficNight = { "mapbox://styles/mapbox/traffic-night-v2", "Traffic Night", 2 }; const DefaultStyle orderedStyles[] = { streets, outdoors, light, dark, satellite, satelliteStreets, - trafficDay, trafficNight, }; const size_t numOrderedStyles = sizeof(orderedStyles) / sizeof(DefaultStyle); diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 6d9eafc042..cdfdb4efe1 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -1519,8 +1519,9 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { [MGLStyle darkStyleURL], [MGLStyle satelliteStyleURL], [MGLStyle satelliteStreetsStyleURL], - [MGLStyle trafficDayStyleURL], - [MGLStyle trafficNightStyleURL], + [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-day-v2"], + [NSURL URLWithString:@"mapbox://styles/mapbox/traffic-night-v2"], + ]; NSAssert(styleNames.count == styleURLs.count, @"Style names and URLs don’t match."); diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index 1d22295f50..3e7f9c14e9 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -182,12 +182,6 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio case 6: styleURL = [MGLStyle satelliteStreetsStyleURL]; break; - case 7: - styleURL = [MGLStyle trafficDayStyleURL]; - break; - case 8: - styleURL = [MGLStyle trafficNightStyleURL]; - break; default: NSAssert(NO, @"Cannot set style from control with tag %li", (long)tag); break; @@ -759,12 +753,6 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio case 6: state = [styleURL isEqual:[MGLStyle satelliteStreetsStyleURL]]; break; - case 7: - state = [styleURL isEqual:[MGLStyle trafficDayStyleURL]]; - break; - case 8: - state = [styleURL isEqual:[MGLStyle trafficNightStyleURL]]; - break; default: return NO; } @@ -926,8 +914,6 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [MGLStyle darkStyleURL], [MGLStyle satelliteStyleURL], [MGLStyle satelliteStreetsStyleURL], - [MGLStyle trafficDayStyleURL], - [MGLStyle trafficNightStyleURL], ]; return [styleURLs indexOfObject:self.mapView.styleURL]; } |