summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-10-29 12:23:50 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-10-30 13:09:37 -0700
commit557b8afb7c310a6330f741ca0f38fcec098f3156 (patch)
tree701483c58128279167261b55f6ecbdfc3353f9a5 /include
parent3b6dc37e396931c883fe6ab602802dbb00defed9 (diff)
downloadqtlocation-mapboxgl-557b8afb7c310a6330f741ca0f38fcec098f3156.tar.gz
[core][iOS] Source iOS styles from default_styles
Moved mbgl::util::default_styles to a more appropriate location, where iOS platform code can also find it. Moved -[MGLMapView bundledStyleURLs] (which is now deprecated) and the style switcher in iosapp to default_styles. Added a collection of convenience methods for getting style URLs. It makes little sense to layer an enum atop this, as MapKit does, because MGLMapView styles aren’t limited to this set. A good analogy is UIColor. This also makes for a good entry point for future runtime styling APIs. Introduced independent constants for each default style, because it’s more common to need access to a particular style than to iterate over them. This fact is apparent in the MGLStyle class, which now uses macros and assertions to ensure that it’s kept up-to-date with changes in default_styles. /ref #1462
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/ios/MGLMapView.h5
-rw-r--r--include/mbgl/ios/MGLStyle.h36
-rw-r--r--include/mbgl/ios/Mapbox.h1
-rw-r--r--include/mbgl/util/default_styles.hpp32
4 files changed, 72 insertions, 2 deletions
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index dd8a120e14..1ff6c9eb6e 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -217,8 +217,9 @@ IB_DESIGNABLE
@property (nonatomic, nullable) NSString *styleID __attribute__((unavailable("Set styleURL to an NSURL of the form <mapbox://styles/STYLE_ID>, where STYLE_ID would have been the value of this property.")));
-/** URLs of the styles bundled with the library. */
-@property (nonatomic, readonly) NS_ARRAY_OF(NSURL *) *bundledStyleURLs;
+/** URLs of the styles bundled with the library.
+ @deprecated Call the relevant class method of `MGLStyle` for the URL of a particular default style. */
+@property (nonatomic, readonly) NS_ARRAY_OF(NSURL *) *bundledStyleURLs __attribute__((deprecated("Call the relevant class method of MGLStyle for the URL of a particular default style.")));
/** URL of the style currently displayed in the receiver.
*
diff --git a/include/mbgl/ios/MGLStyle.h b/include/mbgl/ios/MGLStyle.h
new file mode 100644
index 0000000000..e27b8b32c7
--- /dev/null
+++ b/include/mbgl/ios/MGLStyle.h
@@ -0,0 +1,36 @@
+#import "Mapbox.h"
+
+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. */
+@interface MGLStyle : NSObject
+
+/** Returns the Streets style URL.
+* Mapbox Streets is a complete base map, perfect for incorporating your own data. */
++ (NSURL *)streetsStyleURL;
+
+/** Returns the Emerald style URL.
+* Emerald is a versatile style with emphasis on road networks and public transportation. */
++ (NSURL *)emeraldStyleURL;
+
+/** Returns the Light style URL.
+* Light is a subtle, light-colored backdrop for data visualizations. */
++ (NSURL *)lightStyleURL;
+
+/** Returns the Dark style URL.
+* Dark is a subtle, dark-colored backdrop for data visualizations. */
++ (NSURL *)darkStyleURL;
+
+/** Returns the Satellite style URL.
+* Mapbox Satellite is a beautiful global satellite and aerial imagery layer. */
++ (NSURL *)satelliteStyleURL;
+
+/** Returns the Hybrid style URL.
+* Hybrid combines the global satellite and aerial imagery of Mapbox Satellite with unobtrusive labels. */
++ (NSURL *)hybridStyleURL;
+
+- (instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/include/mbgl/ios/Mapbox.h b/include/mbgl/ios/Mapbox.h
index f05f0c8429..9a1f4f476e 100644
--- a/include/mbgl/ios/Mapbox.h
+++ b/include/mbgl/ios/Mapbox.h
@@ -10,5 +10,6 @@
#import "MGLPolygon.h"
#import "MGLPolyline.h"
#import "MGLShape.h"
+#import "MGLStyle.h"
#import "MGLTypes.h"
#import "MGLUserLocation.h"
diff --git a/include/mbgl/util/default_styles.hpp b/include/mbgl/util/default_styles.hpp
new file mode 100644
index 0000000000..3f5b6bd312
--- /dev/null
+++ b/include/mbgl/util/default_styles.hpp
@@ -0,0 +1,32 @@
+#ifndef MBGL_PLATFORM_DEFAULT_STYLES
+#define MBGL_PLATFORM_DEFAULT_STYLES
+
+#include <vector>
+#include <string>
+
+namespace mbgl {
+namespace util {
+namespace default_styles {
+
+struct DefaultStyle {
+ const char* url;
+ const char* name;
+};
+
+extern const DefaultStyle streets;
+extern const DefaultStyle emerald;
+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,
+};
+const size_t numOrderedStyles = sizeof(orderedStyles) / sizeof(DefaultStyle);
+
+} // end namespace default_styles
+} // end namespace util
+} // end namespace mbgl
+
+#endif