diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index afb5980..051f7f6 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 453090b..5b07244 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 29e63be..b4f7054 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 8fd4c83..a5bce76 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 c422ca9..a81aa81 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")