Migrating mapbox-gl-native to maplibre-gl-native

This commit is contained in:
Dan Paulat 2021-07-11 20:59:53 -05:00
parent d734bc6a0a
commit 7e98227c70
5 changed files with 25 additions and 6 deletions

2
.gitmodules vendored
View file

@ -1,6 +1,6 @@
[submodule "external/mapbox-gl-native"] [submodule "external/mapbox-gl-native"]
path = external/mapbox-gl-native path = external/mapbox-gl-native
url = ../mapbox-gl-native.git url = ../maplibre-gl-native.git
[submodule "external/cmake-conan"] [submodule "external/cmake-conan"]
path = external/cmake-conan path = external/cmake-conan
url = https://github.com/conan-io/cmake-conan.git url = https://github.com/conan-io/cmake-conan.git

View file

@ -4,6 +4,7 @@ project(${PROJECT_NAME} CXX)
set(CMAKE_POLICY_DEFAULT_CMP0054 NEW) set(CMAKE_POLICY_DEFAULT_CMP0054 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0079 NEW)
enable_testing() enable_testing()

@ -1 +1 @@
Subproject commit 40b8010d12e82d0e6505aecedd641de70fe41cf7 Subproject commit f424ec413fecaa0f9121b207d7ae8e667db7ce23

View file

@ -5,6 +5,9 @@ set(gtest_disable_pthreads ON)
set(MBGL_WITH_QT ON) set(MBGL_WITH_QT ON)
add_subdirectory(mapbox-gl-native) add_subdirectory(mapbox-gl-native)
find_package(ZLIB)
target_link_libraries(mbgl-core PUBLIC ZLIB::ZLIB)
set_target_properties(mbgl-qt PROPERTIES EXCLUDE_FROM_ALL True) set_target_properties(mbgl-qt PROPERTIES EXCLUDE_FROM_ALL True)
set_target_properties(mbgl-test-runner PROPERTIES EXCLUDE_FROM_ALL True) set_target_properties(mbgl-test-runner PROPERTIES EXCLUDE_FROM_ALL True)
set_target_properties(mbgl-vendor-icu PROPERTIES EXCLUDE_FROM_ALL True) set_target_properties(mbgl-vendor-icu PROPERTIES EXCLUDE_FROM_ALL True)

View file

@ -16,6 +16,20 @@ namespace scwx
namespace qt namespace qt
{ {
typedef std::pair<std::string, std::string> MapStyle;
// clang-format off
static const MapStyle streets { "mapbox://styles/mapbox/streets-v11", "Streets"};
static const MapStyle outdoors { "mapbox://styles/mapbox/outdoors-v11", "Outdoors"};
static const MapStyle light { "mapbox://styles/mapbox/light-v10", "Light"};
static const MapStyle dark { "mapbox://styles/mapbox/dark-v10", "Dark" };
static const MapStyle satellite { "mapbox://styles/mapbox/satellite-v9", "Satellite" };
static const MapStyle satelliteStreets { "mapbox://styles/mapbox/satellite-streets-v11", "Satellite Streets" };
// clang-format on
static const std::array<MapStyle, 6> mapboxStyles_ = {
{streets, outdoors, light, dark, satellite, satelliteStreets}};
MapWidget::MapWidget(const QMapboxGLSettings& settings) : settings_(settings) MapWidget::MapWidget(const QMapboxGLSettings& settings) : settings_(settings)
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
@ -35,12 +49,13 @@ qreal MapWidget::pixelRatio()
void MapWidget::changeStyle() void MapWidget::changeStyle()
{ {
static uint8_t currentStyleIndex; static uint8_t currentStyleIndex = 0;
auto& styles = QMapbox::defaultStyles(); auto& styles = mapboxStyles_;
map_->setStyleUrl(styles[currentStyleIndex].first); map_->setStyleUrl(styles[currentStyleIndex].first.c_str());
setWindowTitle(QString("Mapbox GL: ") + styles[currentStyleIndex].second); setWindowTitle(QString("Mapbox GL: ") +
styles[currentStyleIndex].second.c_str());
if (++currentStyleIndex == styles.size()) if (++currentStyleIndex == styles.size())
{ {