diff --git a/.jazzy.yaml b/.jazzy.yaml
index 216fd82ae..116ee52c7 100644
--- a/.jazzy.yaml
+++ b/.jazzy.yaml
@@ -22,6 +22,7 @@ custom_categories:
- MGLMapView
- MGLMapViewDelegate
- MGLStyle
+ - MGLStyleCurrentVersion
- MGLUserTrackingMode
- name: Annotations
children:
diff --git a/include/mbgl/util/default_styles.hpp b/include/mbgl/util/default_styles.hpp
index 3f5b6bd31..2043dd3f5 100644
--- a/include/mbgl/util/default_styles.hpp
+++ b/include/mbgl/util/default_styles.hpp
@@ -14,17 +14,19 @@ struct DefaultStyle {
};
extern const DefaultStyle streets;
-extern const DefaultStyle emerald;
+extern const DefaultStyle outdoors;
extern const DefaultStyle light;
extern const DefaultStyle dark;
extern const DefaultStyle satellite;
extern const DefaultStyle hybrid;
const DefaultStyle orderedStyles[] = {
- streets, emerald, light, dark, satellite, hybrid,
+ streets, outdoors, light, dark, satellite, hybrid,
};
const size_t numOrderedStyles = sizeof(orderedStyles) / sizeof(DefaultStyle);
+static const unsigned currentVersion = 9;
+
} // end namespace default_styles
} // end namespace util
} // end namespace mbgl
diff --git a/platform/darwin/include/MGLStyle.h b/platform/darwin/include/MGLStyle.h
index e5b2de877..2a2d61657 100644
--- a/platform/darwin/include/MGLStyle.h
+++ b/platform/darwin/include/MGLStyle.h
@@ -4,50 +4,115 @@
NS_ASSUME_NONNULL_BEGIN
-/** A collection of convenience methods for creating style URLs of default styles provided by Mapbox. These instances of NSURL are cached. */
+/**
+ A version number identifying the latest released version of the suite of default styles provided by Mapbox. This version number may be passed into one of the “StyleURLWithVersion” class methods of MGLStyle.
+
+ The value of this constant is current as of the date on which this SDK was published. Consult the Mapbox Styles API documentation for the most up-to-date style versioning information.
+
+ @warning The value of this constant may change in a future release of the SDK. If you use any feature that depends on a specific implementation detail in a default style, you may use the current value of this constant or the underlying style URL, but do not use the constant itself. Such implementation details may change significantly from version to version.
+ */
+static const NSInteger MGLStyleCurrentVersion = 9;
+
+/**
+ A collection of convenience methods for creating style URLs of default styles provided by Mapbox.
+ */
@interface MGLStyle : NSObject
/**
- Returns the Streets style URL.
+ Returns the URL to the current version of the Streets style.
- Mapbox Streets is a complete base map, perfect for incorporating your own data.
+ Mapbox Streets is a complete base map that balances nature, commerce, and infrastructure.
*/
-+ (NSURL *)streetsStyleURL;
++ (NSURL *)streetsStyleURL __attribute__((deprecated("Use -streetsStyleURLWithVersion:.")));
/**
- Returns the Emerald style URL.
+ Returns the URL to the given version of the Streets style.
- Emerald is a versatile style with emphasis on road networks and public transportation.
+ Mapbox Streets is a complete base map that balances nature, commerce, and infrastructure.
+
+ @param version The style’s latest released version. The current version is given by `MGLStyleCurrentVersion`.
*/
-+ (NSURL *)emeraldStyleURL;
++ (NSURL *)streetsStyleURLWithVersion:(NSInteger)version;
/**
- Returns the Light style URL.
+ Returns the URL to the current version of the Emerald style.
- Light is a subtle, light-colored backdrop for data visualizations.
+ Mapbox Emerald is a versatile style with emphasis on road networks and public transportation.
*/
-+ (NSURL *)lightStyleURL;
++ (NSURL *)emeraldStyleURL __attribute__((deprecated("Use .")));
/**
- Returns the Dark style URL.
+ Returns the URL to the given version of the Outdoors style.
- Dark is a subtle, dark-colored backdrop for data visualizations.
+ Mapbox Outdoors is a rugged style that emphasizes physical terrain and outdoor activities.
+
+ @param version The style’s latest released version. The current version is given by `MGLStyleCurrentVersion`.
*/
-+ (NSURL *)darkStyleURL;
++ (NSURL *)outdoorsStyleURLWithVersion:(NSInteger)version;
/**
- Returns the Satellite style URL.
+ Returns the URL to the current version of the Light style.
+
+ Mapbox Light is a subtle, light-colored backdrop for data visualizations.
+ */
++ (NSURL *)lightStyleURL __attribute__((deprecated("Use -lightStyleURLWithVersion:.")));
+
+/**
+ Returns the URL to the given version of the Light style.
+
+ Mapbox Light is a subtle, light-colored backdrop for data visualizations.
+
+ @param version The style’s latest released version. The current version is given by `MGLStyleCurrentVersion`.
+ */
++ (NSURL *)lightStyleURLWithVersion:(NSInteger)version;
+
+/**
+ Returns the URL to the current version of the Dark style.
+
+ Mapbox Dark is a subtle, dark-colored backdrop for data visualizations.
+ */
++ (NSURL *)darkStyleURL __attribute__((deprecated("Use -darkStyleURLWithVersion:.")));
+
+/**
+ Returns the URL to the given version of the Dark style.
+
+ Mapbox Dark is a subtle, dark-colored backdrop for data visualizations.
+
+ @param version The style’s latest released version. The current version is given by `MGLStyleCurrentVersion`.
+ */
++ (NSURL *)darkStyleURLWithVersion:(NSInteger)version;
+
+/**
+ Returns the URL to the current version of the Satellite style.
Mapbox Satellite is a beautiful global satellite and aerial imagery layer.
*/
-+ (NSURL *)satelliteStyleURL;
++ (NSURL *)satelliteStyleURL __attribute__((deprecated("Use -satelliteStyleURLWithVersion:.")));
/**
- Returns the Hybrid style URL.
+ Returns the URL to the given version of the Satellite style.
- Hybrid combines the global satellite and aerial imagery of Mapbox Satellite with unobtrusive labels.
+ Mapbox Satellite is a beautiful global satellite and aerial imagery layer.
+
+ @param version The style’s latest released version. The current version is given by `MGLStyleCurrentVersion`.
*/
-+ (NSURL *)hybridStyleURL;
++ (NSURL *)satelliteStyleURLWithVersion:(NSInteger)version;
+
+/**
+ Returns the URL to the current version of the Hybrid style.
+
+ Mapbox Hybrid combines the global satellite and aerial imagery of Mapbox Satellite with unobtrusive labels.
+ */
++ (NSURL *)hybridStyleURL __attribute__((deprecated("Use -hybridStyleURLWithVersion:.")));
+
+/**
+ Returns the URL to the given version of the Hybrid style.
+
+ Mapbox Hybrid combines the global satellite and aerial imagery of Mapbox Satellite with unobtrusive labels.
+
+ @param version The style’s latest released version. The current version is given by `MGLStyleCurrentVersion`.
+ */
++ (NSURL *)hybridStyleURLWithVersion:(NSInteger)version;
- (instancetype)init NS_UNAVAILABLE;
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index 15a25db9e..c906337a5 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -4,27 +4,44 @@
@implementation MGLStyle
-// name is lowercase
-#define MGL_DEFINE_STYLE(name) \
+static_assert(mbgl::util::default_styles::currentVersion == MGLStyleCurrentVersion, "mbgl::util::default_styles::currentVersion and MGLStyleCurrentVersion disagree.");
+
+/// @param name The style’s marketing name, written in lower camelCase.
+/// @param fileName The last path component in the style’s URL, excluding the version suffix.
+#define MGL_DEFINE_STYLE(name, fileName) \
static NSURL *MGLStyleURL_##name; \
+ (NSURL *)name##StyleURL { \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
- MGLStyleURL_##name = [NSURL URLWithString:@(mbgl::util::default_styles::name.url)]; \
+ MGLStyleURL_##name = [self name##StyleURLWithVersion:MGLStyleCurrentVersion]; \
}); \
return MGLStyleURL_##name; \
+ } \
+ \
+ + (NSURL *)name##StyleURL##WithVersion:(NSInteger)version { \
+ return [NSURL URLWithString:[@"mapbox://styles/mapbox/" #fileName "-v" stringByAppendingFormat:@"%li", (long)version]]; \
}
-MGL_DEFINE_STYLE(streets)
-MGL_DEFINE_STYLE(emerald)
-MGL_DEFINE_STYLE(light)
-MGL_DEFINE_STYLE(dark)
-MGL_DEFINE_STYLE(satellite)
-MGL_DEFINE_STYLE(hybrid)
+MGL_DEFINE_STYLE(streets, streets)
+MGL_DEFINE_STYLE(outdoors, outdoors)
+MGL_DEFINE_STYLE(light, light)
+MGL_DEFINE_STYLE(dark, dark)
+MGL_DEFINE_STYLE(satellite, satellite)
+MGL_DEFINE_STYLE(hybrid, satellite-hybrid)
// Make sure all the styles listed in mbgl::util::default_styles::orderedStyles
// are defined above and also declared in MGLStyle.h.
static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
"mbgl::util::default_styles::orderedStyles and MGLStyle have different numbers of styles.");
+// Emerald is no longer getting new versions as a default style, so the current version is hard-coded here.
+static NSURL *MGLStyleURL_emerald;
++ (NSURL *)emeraldStyleURL {
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ MGLStyleURL_emerald = [NSURL URLWithString:@"mapbox://styles/mapbox/emerald-v8"];
+ });
+ return MGLStyleURL_emerald;
+}
+
@end
diff --git a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
index d1151de09..9b33d267d 100644
--- a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
+++ b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm
@@ -33,7 +33,7 @@
- (instancetype)initWithStyleURL:(NSURL *)styleURL bounds:(MGLCoordinateBounds)bounds fromZoomLevel:(double)minimumZoomLevel toZoomLevel:(double)maximumZoomLevel {
if (self = [super init]) {
if (!styleURL) {
- styleURL = [MGLStyle streetsStyleURL];
+ styleURL = [MGLStyle streetsStyleURLWithVersion:MGLStyleCurrentVersion];
}
if (!styleURL.scheme) {
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md
index b560535be..c3138058d 100644
--- a/platform/ios/CHANGELOG.md
+++ b/platform/ios/CHANGELOG.md
@@ -2,6 +2,12 @@
Mapbox welcomes participation and contributions from everyone. If you’d like to do so please see [CONTRIBUTING.md](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started.
+## 3.2.2
+
+- Existing MGLStyle class methods that return default style URLs have been deprecated in favor of new methods that require an explicit style version parameter. ([#4759](https://github.com/mapbox/mapbox-gl-native/pull/4759))
+- Deprecated `+[MGLStyle emeraldStyleURL]` with no replacement method. To use the Emerald style going forward, we recommend that you use the underlying URL. ([#4759](https://github.com/mapbox/mapbox-gl-native/pull/4759))
+- Added `+[MGLStyle outdoorsStyleURLWithVersion:]` for the new Outdoors style. ([#4759](https://github.com/mapbox/mapbox-gl-native/pull/4759))
+
## 3.2.1
- Fixed a hang that could occur if the host application attempts to set user defaults on a background queue. ([#4745](https://github.com/mapbox/mapbox-gl-native/pull/4745))
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 17323720a..8d6688e7e 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -276,7 +276,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
if ( ! styleURL)
{
- styleURL = [MGLStyle streetsStyleURL];
+ styleURL = [MGLStyle streetsStyleURLWithVersion:MGLStyleCurrentVersion];
}
if ( ! [styleURL scheme])
diff --git a/platform/osx/app/MainMenu.xib b/platform/osx/app/MainMenu.xib
index 646c4ae40..3776d0d16 100644
--- a/platform/osx/app/MainMenu.xib
+++ b/platform/osx/app/MainMenu.xib
@@ -370,7 +370,7 @@
-