summaryrefslogtreecommitdiff
path: root/linux/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linux/main.cpp')
-rw-r--r--linux/main.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/linux/main.cpp b/linux/main.cpp
index 738bbfb0aa..2361c996d6 100644
--- a/linux/main.cpp
+++ b/linux/main.cpp
@@ -1,4 +1,5 @@
#include <mbgl/mbgl.hpp>
+#include "../platform/default/default_styles.hpp"
#include <mbgl/util/std.hpp>
#include <mbgl/util/uv.hpp>
#include <mbgl/platform/log.hpp>
@@ -13,9 +14,12 @@
#include <fstream>
#include <sstream>
+namespace {
std::unique_ptr<GLFWView> view;
+}
+
void quit_handler(int) {
if (view) {
mbgl::Log::Info(mbgl::Event::Setup, "waiting for quit...");
@@ -75,6 +79,19 @@ int main(int argc, char *argv[]) {
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
const char *token = getenv("MAPBOX_ACCESS_TOKEN");
if (token == nullptr) {
@@ -85,7 +102,7 @@ int main(int argc, char *argv[]) {
// Load style
if (style.empty()) {
- style = std::string("asset://") + std::string("styles/bright-v7.json");
+ style = mbgl::util::defaultStyles.front().first;
}
map.setStyleURL(style);