DefaultFileSource has responsibility for handling mapbox:// URLs

This commit is contained in:
John Firebaugh
2015-05-20 08:21:29 -07:00
committed by Konstantin Käfer
parent f11a9f8fd9
commit 87b1da7611
16 changed files with 62 additions and 71 deletions

View File

@@ -70,6 +70,15 @@ int main(int argc, char *argv[]) {
mbgl::SQLiteCache cache("/tmp/mbgl-cache.db");
mbgl::DefaultFileSource fileSource(&cache);
// Set access token if present
const char *token = getenv("MAPBOX_ACCESS_TOKEN");
if (token == nullptr) {
mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work.");
} else {
fileSource.setAccessToken(std::string(token));
}
mbgl::Map map(*view, fileSource);
// Load settings
@@ -92,14 +101,6 @@ int main(int argc, char *argv[]) {
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) {
mbgl::Log::Warning(mbgl::Event::Setup, "no access token set. mapbox.com tiles won't work.");
} else {
map.setAccessToken(std::string(token));
}
// Load style
if (style.empty()) {
const auto& newStyle = mbgl::util::defaultStyles.front();