Renamed MGLStyleCurrentVersion to MGLStyleDefaultVersion to emphasize the constant’s role as an indicator of the default version used by SDK classes, which may be behind depending on release schedules. In the documentation for each style URL method, include the actual version number instead of the constant. In unit tests, verify that this documentation is in sync with the constant. Link each style URL method’s documentation to a forthcoming webpage on mapbox.com that describes the style in rich detail.
58 lines
2.2 KiB
Plaintext
58 lines
2.2 KiB
Plaintext
#import "MGLStyle.h"
|
||
|
||
#import <mbgl/util/default_styles.hpp>
|
||
|
||
@implementation MGLStyle
|
||
|
||
static_assert(mbgl::util::default_styles::currentVersion == MGLStyleDefaultVersion, "mbgl::util::default_styles::currentVersion and MGLStyleDefaultVersion 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 = [self name##StyleURLWithVersion:8]; \
|
||
}); \
|
||
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, streets)
|
||
MGL_DEFINE_STYLE(outdoors, outdoors)
|
||
MGL_DEFINE_STYLE(light, light)
|
||
MGL_DEFINE_STYLE(dark, dark)
|
||
MGL_DEFINE_STYLE(satellite, satellite)
|
||
MGL_DEFINE_STYLE(satelliteStreets, satellite-streets)
|
||
|
||
// 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.");
|
||
|
||
// Hybrid has been renamed Satellite Streets, so the last Hybrid version is hard-coded here.
|
||
static NSURL *MGLStyleURL_hybrid;
|
||
+ (NSURL *)hybridStyleURL {
|
||
static dispatch_once_t onceToken;
|
||
dispatch_once(&onceToken, ^{
|
||
MGLStyleURL_hybrid = [NSURL URLWithString:@"mapbox://styles/mapbox/satellite-hybrid-v8"];
|
||
});
|
||
return MGLStyleURL_hybrid;
|
||
}
|
||
|
||
// 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
|