diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-05-07 10:16:04 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-05-07 11:01:15 +0200 |
commit | b7fa1d719677e7782d9a53f8fce92c09b15eba12 (patch) | |
tree | 13451d62afe633a1010fddf5bc177d4a86494546 /macosx | |
parent | 769364c117dfa618801fa4d90b74043bb46b8092 (diff) | |
download | qtlocation-mapboxgl-b7fa1d719677e7782d9a53f8fce92c09b15eba12.tar.gz |
add style cycling to Mac OS X app as well
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/main.mm | 17 | ||||
-rw-r--r-- | macosx/mapboxgl-app.gypi | 2 |
2 files changed, 18 insertions, 1 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index 28d78e442a..7922ee7c0e 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,4 +1,5 @@ #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> @@ -125,13 +126,27 @@ int main() { map.setBearing(settings.bearing); map.setDebug(settings.debug); + view.setChangeStyleCallback([&map] () { + static uint8_t currentStyleIndex; + + if (++currentStyleIndex == mbgl::util::defaultStyles.size()) { + currentStyleIndex = 0; + } + + const auto& newStyle = mbgl::util::defaultStyles[currentStyleIndex]; + map.setStyleURL(newStyle.first); + + mbgl::Log::Info(mbgl::Event::Setup, std::string("Changed style to: ") + newStyle.first); + }); + // Set access token if present NSString *accessToken = [[NSProcessInfo processInfo] environment][@"MAPBOX_ACCESS_TOKEN"]; if (!accessToken) mbgl::Log::Warning(mbgl::Event::Setup, "No access token set. Mapbox vector tiles won't work."); if (accessToken) map.setAccessToken([accessToken cStringUsingEncoding:[NSString defaultCStringEncoding]]); // Load style - map.setStyleURL("asset://styles/bright-v7.json"); + const auto& newStyle = mbgl::util::defaultStyles.front(); + map.setStyleURL(newStyle.first); view.run(); diff --git a/macosx/mapboxgl-app.gypi b/macosx/mapboxgl-app.gypi index 3817954042..c56bca659f 100644 --- a/macosx/mapboxgl-app.gypi +++ b/macosx/mapboxgl-app.gypi @@ -28,6 +28,8 @@ '../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' : { |