From 557b8afb7c310a6330f741ca0f38fcec098f3156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 29 Oct 2015 12:23:50 -0700 Subject: [core][iOS] Source iOS styles from default_styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- linux/main.cpp | 18 +++++++++--------- linux/mapboxgl-app.gypi | 2 -- 2 files changed, 9 insertions(+), 11 deletions(-) (limited to 'linux') diff --git a/linux/main.cpp b/linux/main.cpp index 6bd2f7c430..81bb684650 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -1,5 +1,5 @@ #include -#include "../platform/default/default_styles.hpp" +#include #include #include #include @@ -131,22 +131,22 @@ int main(int argc, char *argv[]) { view->setChangeStyleCallback([&map] () { 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/linux/mapboxgl-app.gypi b/linux/mapboxgl-app.gypi index 8299dc1e76..39061434e0 100644 --- a/linux/mapboxgl-app.gypi +++ b/linux/mapboxgl-app.gypi @@ -22,8 +22,6 @@ '../platform/default/glfw_view.hpp', '../platform/default/glfw_view.cpp', '../platform/default/log_stderr.cpp', - '../platform/default/default_styles.hpp', - '../platform/default/default_styles.cpp', ], 'variables' : { -- cgit v1.2.1