diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index afb59804da64059acecbe43f90f57fb8078767ac..051f7f6118940a04f3cd04a2cb6a031e949d4083 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -95,8 +95,7 @@ Map { function updateActiveMapType() { var settings = QGroundControl.settingsManager.flightMapSettings - //var fullMapName = settings.mapProvider.value + " " + settings.mapType.value - var fullMapName = settings.mapProvider.value + var fullMapName = settings.mapProvider.value + " " + settings.mapType.value console.log("updateActiveMapType",fullMapName) for (var i = 0; i < _map.supportedMapTypes.length; i++) { diff --git a/src/QtLocationPlugin/QGCMapUrlEngine.cpp b/src/QtLocationPlugin/QGCMapUrlEngine.cpp index 453090b049feee62427da2065e1fe0365b3add84..5b07244cd50023d790ec78cf8d564e8447523620 100644 --- a/src/QtLocationPlugin/QGCMapUrlEngine.cpp +++ b/src/QtLocationPlugin/QGCMapUrlEngine.cpp @@ -36,6 +36,8 @@ UrlFactory::UrlFactory() : _timeout(5 * 1000) { // BingMaps //_versionBingMaps = "563"; + + // Warning : in _providersTable, keys needs to follow this format : "Provider Type" #ifndef QGC_NO_GOOGLE_MAPS _providersTable["Google Street Map"] = new GoogleStreetMapProvider(this); _providersTable["Google Satellite"] = new GoogleSatelliteMapProvider(this); @@ -532,7 +534,7 @@ QString UrlFactory::getTypeFromId(int id) { return i.key(); } } - qCDebug(QGCMapUrlEngineLog) << "getTypeFromId : id not found" << id + qCDebug(QGCMapUrlEngineLog) << "getTypeFromId : id not found" << id; return ""; } diff --git a/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc b/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc index 29e63be5e783b6f800a2d0e4f90ea38fb0f87679..b4f705485f5894f1d275f30d51418c38c548ba6f 100644 --- a/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc +++ b/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc @@ -216,6 +216,27 @@ QGCMapEngineManager::mapList() { return getQGCMapEngine()->getMapNameList(); } +//----------------------------------------------------------------------------- +QStringList +QGCMapEngineManager::mapProviderList() +{ + // Extract Provider name from MapName ( format : "Provider Type") + QStringList mapList = getQGCMapEngine()->getMapNameList(); + mapList.replaceInStrings(QRegExp("^([^\\ ]*) (.*)$"),"\\1"); + mapList.removeDuplicates(); + return mapList; +} + +//----------------------------------------------------------------------------- +QStringList +QGCMapEngineManager::mapTypeList() +{ + // Extract type name from MapName ( format : "Provider Type") + QStringList mapList = getQGCMapEngine()->getMapNameList(); + mapList.replaceInStrings(QRegExp("^([^\\ ]*) (.*)"),"\\2"); + mapList.removeDuplicates(); + return mapList; +} //----------------------------------------------------------------------------- quint32 diff --git a/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h b/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h index 8fd4c833412420bb95159f153e07f751c3bffd23..a5bce7635c3add2c72a6bd17958704e1858ce79c 100644 --- a/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h +++ b/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h @@ -43,6 +43,8 @@ public: Q_PROPERTY(QString tileSizeStr READ tileSizeStr NOTIFY tileSizeChanged) Q_PROPERTY(QmlObjectListModel* tileSets READ tileSets NOTIFY tileSetsChanged) Q_PROPERTY(QStringList mapList READ mapList CONSTANT) + Q_PROPERTY(QStringList mapProviderList READ mapProviderList CONSTANT) + Q_PROPERTY(QStringList mapTypeList READ mapTypeList CONSTANT) Q_PROPERTY(quint32 maxMemCache READ maxMemCache WRITE setMaxMemCache NOTIFY maxMemCacheChanged) Q_PROPERTY(quint32 maxDiskCache READ maxDiskCache WRITE setMaxDiskCache NOTIFY maxDiskCacheChanged) Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged) @@ -77,6 +79,8 @@ public: quint64 tileSize () { return _imageSet.tileSize + _elevationSet.tileSize; } QString tileSizeStr (); QStringList mapList (); + QStringList mapProviderList (); + QStringList mapTypeList (); QmlObjectListModel* tileSets () { return &_tileSets; } quint32 maxMemCache (); quint32 maxDiskCache (); diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index c422ca9e65d843ae6f316d1077fa0b6e79a24237..a81aa812c3cb26eb2b805d2ad631704ce0d28cfc 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -160,11 +160,11 @@ Rectangle { QGCLabel { text: qsTr("Map Provider") width: _labelWidth - //visible: _mapProvider.visible } + QGCComboBox { id: mapCombo - model: QGroundControl.mapEngineManager.mapList + model: QGroundControl.mapEngineManager.mapProviderList Layout.preferredWidth: _comboFieldWidth onActivated: { _mapProvider = textAt(index) @@ -175,6 +175,23 @@ Rectangle { mapCombo.currentIndex = index } } + QGCLabel { + text: qsTr("Map Type") + width: _labelWidth + } + QGCComboBox { + id: mapTypeCombo + model: QGroundControl.mapEngineManager.mapTypeList + Layout.preferredWidth: _comboFieldWidth + onActivated: { + _mapType = textAt(index) + QGroundControl.settingsManager.flightMapSettings.mapType.value=textAt(index) + } + Component.onCompleted: { + var index = mapTypeCombo.find(_mapType) + mapTypeCombo.currentIndex = index + } + } QGCLabel { text: qsTr("Stream GCS Position")