summaryrefslogtreecommitdiff
path: root/macosx
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 /macosx
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 'macosx')
-rw-r--r--macosx/main.mm18
-rw-r--r--macosx/mapboxgl-app.gypi2
2 files changed, 9 insertions, 11 deletions
diff --git a/macosx/main.mm b/macosx/main.mm
index 34cd7872b5..7d5226d246 100644
--- a/macosx/main.mm
+++ b/macosx/main.mm
@@ -1,5 +1,4 @@
#include <mbgl/platform/log.hpp>
-#include "../platform/default/default_styles.hpp"
#include <mbgl/platform/platform.hpp>
#include <mbgl/platform/darwin/settings_nsuserdefaults.hpp>
#include <mbgl/platform/darwin/reachability.h>
@@ -9,6 +8,7 @@
#include <mbgl/storage/network_status.hpp>
#include <mbgl/util/geo.hpp>
+#include <mbgl/util/default_styles.hpp>
#import <Foundation/Foundation.h>
@@ -172,23 +172,23 @@ int main(int argc, char* argv[]) {
view.setChangeStyleCallback([&map, &view] () {
static uint8_t currentStyleIndex;
- if (++currentStyleIndex == mbgl::util::defaultStyles.size()) {
+ if (++currentStyleIndex == mbgl::util::default_styles::numOrderedStyles) {
currentStyleIndex = 0;
}
- const auto& newStyle = mbgl::util::defaultStyles[currentStyleIndex];
- map.setStyleURL(newStyle.first);
- view.setWindowTitle(newStyle.second);
+ mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[currentStyleIndex];
+ map.setStyleURL(newStyle.url);
+ view.setWindowTitle(newStyle.name);
- mbgl::Log::Info(mbgl::Event::Setup, std::string("Changed style to: ") + newStyle.first);
+ mbgl::Log::Info(mbgl::Event::Setup, std::string("Changed style to: ") + newStyle.name);
});
// Load style
if (style.empty()) {
- const auto& newStyle = mbgl::util::defaultStyles.front();
- style = newStyle.first;
- view.setWindowTitle(newStyle.second);
+ mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[0];
+ style = newStyle.url;
+ view.setWindowTitle(newStyle.name);
}
map.setStyleURL(style);
diff --git a/macosx/mapboxgl-app.gypi b/macosx/mapboxgl-app.gypi
index 3f16e8e89d..283e001c44 100644
--- a/macosx/mapboxgl-app.gypi
+++ b/macosx/mapboxgl-app.gypi
@@ -27,8 +27,6 @@
'../platform/darwin/reachability.m',
'../platform/default/glfw_view.hpp',
'../platform/default/glfw_view.cpp',
- '../platform/default/default_styles.hpp',
- '../platform/default/default_styles.cpp',
],
'variables' : {