With MapTiler, use https for style URLs

- Eliminates issues with rewriting maptiler:// to incorrect URLs
This commit is contained in:
Dan Paulat 2024-03-02 00:10:21 -06:00
parent a74fb22c88
commit e0c1138250
5 changed files with 49 additions and 19 deletions

View file

@ -88,6 +88,21 @@ glm::vec2 LatLongToScreenCoordinate(const QMapLibre::Coordinate& coordinate)
return screen;
}
void SetMapStyleUrl(const std::shared_ptr<QMapLibre::Map>& map,
map::MapProvider mapProvider,
const std::string& url)
{
QString qUrl = QString::fromStdString(url);
if (mapProvider == map::MapProvider::MapTiler)
{
qUrl.append("?key=");
qUrl.append(map::GetMapProviderApiKey(mapProvider));
}
map->setStyleUrl(qUrl);
}
} // namespace maplibre
} // namespace util
} // namespace qt

View file

@ -1,5 +1,8 @@
#pragma once
#include <scwx/qt/map/map_provider.hpp>
#include <QMapLibre/Map>
#include <QMapLibre/Types>
#include <glm/gtc/type_ptr.hpp>
#include <units/length.h>
@ -31,6 +34,10 @@ bool IsPointInPolygon(const std::vector<glm::vec2>& vertices,
glm::vec2 LatLongToScreenCoordinate(const QMapLibre::Coordinate& coordinate);
void SetMapStyleUrl(const std::shared_ptr<QMapLibre::Map>& map,
map::MapProvider mapProvider,
const std::string& url);
} // namespace maplibre
} // namespace util
} // namespace qt