|
|
|
@ -22,6 +22,12 @@ const float MAP_SCALE = 2; |
|
|
|
|
MapWindow::MapWindow(const QMapLibre::Settings &settings) : m_settings(settings), velocity_filter(0, 10, 0.05, false) { |
|
|
|
|
QObject::connect(uiState(), &UIState::uiUpdate, this, &MapWindow::updateState); |
|
|
|
|
|
|
|
|
|
reinit_timer.setSingleShot(true); |
|
|
|
|
QObject::connect(&reinit_timer, &QTimer::timeout, this, [=] { |
|
|
|
|
m_settings.setApiKey(get_mapbox_token()); |
|
|
|
|
initializeGL(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
map_overlay = new QWidget (this); |
|
|
|
|
map_overlay->setAttribute(Qt::WA_TranslucentBackground, true); |
|
|
|
|
QVBoxLayout *overlay_layout = new QVBoxLayout(map_overlay); |
|
|
|
@ -256,10 +262,11 @@ void MapWindow::initializeGL() { |
|
|
|
|
|
|
|
|
|
QObject::connect(m_map.data(), &QMapLibre::Map::mapLoadingFailed, [=](QMapLibre::Map::MapLoadingFailure err_code, const QString &reason) { |
|
|
|
|
LOGE("Map loading failed with %d: '%s'\n", err_code, reason.toStdString().c_str()); |
|
|
|
|
// if time is wrong, re-create token and try connecting again in 5s
|
|
|
|
|
if (err_code == QMapLibre::Map::MapLoadingFailure::StyleLoadFailure && reason.contains("SSL handshake failed")) { |
|
|
|
|
m_settings.setApiKey(get_mapbox_token()); |
|
|
|
|
QTimer::singleShot(5000, this, &MapWindow::initializeGL); |
|
|
|
|
// time could be wrong, re-create token and try connecting again in 5s
|
|
|
|
|
if (err_code == QMapLibre::Map::MapLoadingFailure::StyleLoadFailure && !loaded_once) { |
|
|
|
|
if (!reinit_timer.isActive()) { |
|
|
|
|
reinit_timer.start(5000); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|