read access token from environment
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
const char *mapbox_access_token = "<your access token here>";
|
||||
Submodule ios/mapbox-gl-cocoa updated: 3b1dd5dddc...565299b7a1
@@ -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();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "../common/settings_nsuserdefaults.hpp"
|
||||
#include "../common/glfw_view.hpp"
|
||||
#include "../access_token.hpp"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user