maps: allow using MAPBOX_TOKEN env variable (#22721)

old-commit-hash: 0ba40954b9bf6810e223600c30affdc15a2b4f9c
This commit is contained in:
Willem Melching
2021-10-28 16:13:44 +02:00
committed by GitHub
parent 67f41f32f1
commit 8d9783a379
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -27,7 +27,8 @@
#include "selfdrive/common/util.h"
#include "cereal/messaging/messaging.h"
const QString MAPS_HOST = util::getenv("MAPS_HOST", "https://maps.comma.ai").c_str();
const QString MAPBOX_TOKEN = util::getenv("MAPBOX_TOKEN").c_str();
const QString MAPS_HOST = util::getenv("MAPS_HOST", MAPBOX_TOKEN.isEmpty() ? "https://maps.comma.ai" : "https://api.mapbox.com").c_str();
class MapInstructions : public QWidget {
Q_OBJECT
+2 -2
View File
@@ -79,11 +79,11 @@ void OnroadWindow::mousePressEvent(QMouseEvent* e) {
void OnroadWindow::offroadTransition(bool offroad) {
#ifdef ENABLE_MAPS
if (!offroad) {
if (map == nullptr && QUIState::ui_state.has_prime) {
if (map == nullptr && (QUIState::ui_state.has_prime || !MAPBOX_TOKEN.isEmpty())) {
QMapboxGLSettings settings;
// Valid for 4 weeks since we can't swap tokens on the fly
QString token = CommaApi::create_jwt({}, 4 * 7 * 24 * 3600);
QString token = MAPBOX_TOKEN.isEmpty() ? CommaApi::create_jwt({}, 4 * 7 * 24 * 3600) : MAPBOX_TOKEN;
if (!Hardware::PC()) {
settings.setCacheDatabasePath("/data/mbgl-cache.db");