maps: allow using MAPBOX_TOKEN env variable (#22721)

pull/22722/head
Willem Melching 2021-10-28 16:13:44 +02:00 committed by GitHub
parent b816b5b644
commit 0ba40954b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

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

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");