From 0d7b3462e9e72190d41341e7da243d6f0732e4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 10 Jul 2014 11:27:03 -0700 Subject: [PATCH] read access token from environment --- .gitignore | 1 - access_token.hpp | 1 - ios/mapbox-gl-cocoa | 2 +- linux/main.cpp | 10 ++++++++-- macosx/main.mm | 10 ++++++++-- 5 files changed, 17 insertions(+), 7 deletions(-) delete mode 100644 access_token.hpp diff --git a/.gitignore b/.gitignore index 6cdd23455..5cf9666f5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,4 @@ /src/shader/shaders_gl.cpp /src/shader/shaders_gles2.cpp /bin/style.bin.js -access_token.hpp /test/fixtures/styles/index.html diff --git a/access_token.hpp b/access_token.hpp deleted file mode 100644 index 22815bad6..000000000 --- a/access_token.hpp +++ /dev/null @@ -1 +0,0 @@ -const char *mapbox_access_token = ""; diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 3b1dd5ddd..565299b7a 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 3b1dd5dddc179653870a0da2b773ae44b74094c1 +Subproject commit 565299b7a18286802f0c49560f34b36835cf06de diff --git a/linux/main.cpp b/linux/main.cpp index eee714750..889a246c2 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -8,7 +8,6 @@ #include "../common/settings_json.hpp" #include "../common/glfw_view.hpp" -#include "../access_token.hpp" GLFWView *view = nullptr; @@ -61,8 +60,15 @@ int main(int argc, char *argv[]) { map.setAngle(settings.angle); map.setDebug(settings.debug); + // Set access token if present + const char *token = getenv("MAPBOX_ACCESS_TOKEN"); + if (token == nullptr) { + fprintf(stderr, "[WARNING] no access token set. mapbox.com tiles won't work.\n"); + } else { + map.setAccessToken(std::string(token)); + } + // Load style - map.setAccessToken(mapbox_access_token); map.setStyleJSON(stylejson.str()); int ret = view->run(); diff --git a/macosx/main.mm b/macosx/main.mm index d04da2b43..3b01df04e 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,6 +1,5 @@ #include "../common/settings_nsuserdefaults.hpp" #include "../common/glfw_view.hpp" -#include "../access_token.hpp" #import @@ -14,8 +13,15 @@ int main() { map.setAngle(settings.angle); map.setDebug(settings.debug); + // Set access token if present + const char *token = getenv("MAPBOX_ACCESS_TOKEN"); + if (token == nullptr) { + fprintf(stderr, "[WARNING] no access token set. mapbox.com tiles won't work.\n"); + } else { + map.setAccessToken(std::string(token)); + } + // Load style - map.setAccessToken(mapbox_access_token); NSString *path = [[NSBundle mainBundle] pathForResource:@"style.min" ofType:@"js"]; NSString *json = [NSString stringWithContentsOfFile:path encoding:[NSString defaultCStringEncoding]