Commit e9914d19 authored by dogmaphobic's avatar dogmaphobic

Restrict map providers for iOS.

parent 0538e94e
...@@ -71,6 +71,7 @@ equals(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 5) { ...@@ -71,6 +71,7 @@ equals(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 5) {
message("iOS build") message("iOS build")
CONFIG += iOSBuild MobileBuild app_bundle CONFIG += iOSBuild MobileBuild app_bundle
DEFINES += __ios__ DEFINES += __ios__
DEFINES += QGC_NO_GOOGLE_MAPS
QMAKE_IOS_DEPLOYMENT_TARGET = 8.0 QMAKE_IOS_DEPLOYMENT_TARGET = 8.0
QMAKE_IOS_TARGETED_DEVICE_FAMILY = 1,2 # Universal QMAKE_IOS_TARGETED_DEVICE_FAMILY = 1,2 # Universal
QMAKE_LFLAGS += -Wl,-no_pie QMAKE_LFLAGS += -Wl,-no_pie
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>QGroundControl</string> <string>QGroundControl</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>qgroundcontrol</string> <string>$(EXECUTABLE_NAME)</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Open Source Flight Systems GmbH - Internal Build</string> <string>Open Source Flight Systems GmbH - Internal Build</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>org.QGroundControl.qgc</string> <string>org.QGroundControl.qgc</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>QGroundControl</string> <string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
......
...@@ -27,33 +27,33 @@ FlightMapSettings::FlightMapSettings(QGCApplication* app) ...@@ -27,33 +27,33 @@ FlightMapSettings::FlightMapSettings(QGCApplication* app)
void FlightMapSettings::setToolbox(QGCToolbox *toolbox) void FlightMapSettings::setToolbox(QGCToolbox *toolbox)
{ {
QGCTool::setToolbox(toolbox); QGCTool::setToolbox(toolbox);
qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only"); qmlRegisterUncreatableType<FlightMapSettings> ("QGroundControl", 1, 0, "FlightMapSetting", "Reference only");
_supportedMapProviders << "Bing";
_supportedMapProviders << "Bing" << "Google"; // << "OpenStreetMap"; #ifndef QGC_NO_GOOGLE_MAPS
_supportedMapProviders << "Google";
#endif
_loadSettings(); _loadSettings();
} }
void FlightMapSettings::_storeSettings(void) void FlightMapSettings::_storeSettings(void)
{ {
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider); settings.setValue(_mapProviderKey, _supportedMapProviders.contains(_mapProvider) ? _mapProvider : _defaultMapProvider);
} }
void FlightMapSettings::_loadSettings(void) void FlightMapSettings::_loadSettings(void)
{ {
#ifdef QGC_NO_GOOGLE_MAPS
_mapProvider = _defaultMapProvider;
#else
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
_mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString(); _mapProvider = settings.value(_mapProviderKey, _defaultMapProvider).toString();
if (!_supportedMapProviders.contains(_mapProvider)) { if (!_supportedMapProviders.contains(_mapProvider)) {
_mapProvider = _defaultMapProvider; _mapProvider = _defaultMapProvider;
} }
#endif
_setMapTypesForCurrentProvider(); _setMapTypesForCurrentProvider();
} }
...@@ -75,24 +75,21 @@ void FlightMapSettings::setMapProvider(const QString& mapProvider) ...@@ -75,24 +75,21 @@ void FlightMapSettings::setMapProvider(const QString& mapProvider)
void FlightMapSettings::_setMapTypesForCurrentProvider(void) void FlightMapSettings::_setMapTypesForCurrentProvider(void)
{ {
_mapTypes.clear(); _mapTypes.clear();
#ifdef QGC_NO_GOOGLE_MAPS
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map";
#else
if (_mapProvider == "Bing") { if (_mapProvider == "Bing") {
_mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map"; _mapTypes << "Street Map" << "Satellite Map" << "Hybrid Map";
} else if (_mapProvider == "Google") { } else if (_mapProvider == "Google") {
_mapTypes << "Street Map" << "Satellite Map" << "Terrain Map"; _mapTypes << "Street Map" << "Satellite Map" << "Terrain Map";
/*
} else if (_mapProvider == "OpenStreetMap") {
_mapTypes << "Street Map";
*/
} }
#endif
emit mapTypesChanged(_mapTypes); emit mapTypesChanged(_mapTypes);
} }
QString FlightMapSettings::mapType(void) QString FlightMapSettings::mapType(void)
{ {
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
settings.beginGroup(_mapProvider); settings.beginGroup(_mapProvider);
return settings.value(_mapTypeKey, "Satellite Map").toString(); return settings.value(_mapTypeKey, "Satellite Map").toString();
...@@ -101,18 +98,15 @@ QString FlightMapSettings::mapType(void) ...@@ -101,18 +98,15 @@ QString FlightMapSettings::mapType(void)
void FlightMapSettings::setMapType(const QString& mapType) void FlightMapSettings::setMapType(const QString& mapType)
{ {
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
settings.beginGroup(_mapProvider); settings.beginGroup(_mapProvider);
settings.setValue(_mapTypeKey, mapType); settings.setValue(_mapTypeKey, mapType);
emit mapTypeChanged(mapType); emit mapTypeChanged(mapType);
} }
void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value) void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& key, const QString& value)
{ {
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName); settings.beginGroup(mapName);
settings.setValue(key, value); settings.setValue(key, value);
...@@ -121,7 +115,6 @@ void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& k ...@@ -121,7 +115,6 @@ void FlightMapSettings::saveMapSetting (const QString &mapName, const QString& k
QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue) QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue)
{ {
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName); settings.beginGroup(mapName);
return settings.value(key, defaultValue).toString(); return settings.value(key, defaultValue).toString();
...@@ -130,7 +123,6 @@ QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString ...@@ -130,7 +123,6 @@ QString FlightMapSettings::loadMapSetting (const QString &mapName, const QString
void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QString& key, bool value) void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QString& key, bool value)
{ {
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName); settings.beginGroup(mapName);
settings.setValue(key, value); settings.setValue(key, value);
...@@ -139,7 +131,6 @@ void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QStrin ...@@ -139,7 +131,6 @@ void FlightMapSettings::saveBoolMapSetting (const QString &mapName, const QStrin
bool FlightMapSettings::loadBoolMapSetting (const QString &mapName, const QString& key, bool defaultValue) bool FlightMapSettings::loadBoolMapSetting (const QString &mapName, const QString& key, bool defaultValue)
{ {
QSettings settings; QSettings settings;
settings.beginGroup(_settingsGroup); settings.beginGroup(_settingsGroup);
settings.beginGroup(mapName); settings.beginGroup(mapName);
return settings.value(key, defaultValue).toBool(); return settings.value(key, defaultValue).toBool();
......
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
/*
TODO: Map settings should come from QGCMapEngineManager. What is currently in
FlightMapSettings should be moved there so all map related funtions are in
one place.
*/
class FlightMapSettings : public QGCTool class FlightMapSettings : public QGCTool
{ {
Q_OBJECT Q_OBJECT
...@@ -35,6 +41,9 @@ public: ...@@ -35,6 +41,9 @@ public:
/// Map type to be used for all maps /// Map type to be used for all maps
Q_PROPERTY(QString mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged) Q_PROPERTY(QString mapType READ mapType WRITE setMapType NOTIFY mapTypeChanged)
/// Is Google Maps Enabled
Q_PROPERTY(bool googleMapEnabled READ googleMapEnabled CONSTANT)
Q_INVOKABLE void saveMapSetting (const QString &mapName, const QString& key, const QString& value); Q_INVOKABLE void saveMapSetting (const QString &mapName, const QString& key, const QString& value);
Q_INVOKABLE QString loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue); Q_INVOKABLE QString loadMapSetting (const QString &mapName, const QString& key, const QString& defaultValue);
Q_INVOKABLE void saveBoolMapSetting (const QString &mapName, const QString& key, bool value); Q_INVOKABLE void saveBoolMapSetting (const QString &mapName, const QString& key, bool value);
...@@ -53,6 +62,13 @@ public: ...@@ -53,6 +62,13 @@ public:
QStringList mapProviders() { return _supportedMapProviders; } QStringList mapProviders() { return _supportedMapProviders; }
#ifdef QGC_NO_GOOGLE_MAPS
bool googleMapEnabled () { return false; }
#else
bool googleMapEnabled () { return true; }
#endif
signals: signals:
void mapProviderChanged (const QString& mapProvider); void mapProviderChanged (const QString& mapProvider);
void mapTypesChanged (const QStringList& mapTypes); void mapTypesChanged (const QStringList& mapTypes);
......
...@@ -43,9 +43,11 @@ struct stQGeoTileCacheQGCMapTypes { ...@@ -43,9 +43,11 @@ struct stQGeoTileCacheQGCMapTypes {
// Changes here must reflect those in QGeoTiledMappingManagerEngineQGC.cpp // Changes here must reflect those in QGeoTiledMappingManagerEngineQGC.cpp
stQGeoTileCacheQGCMapTypes kMapTypes[] = { stQGeoTileCacheQGCMapTypes kMapTypes[] = {
#ifndef QGC_LIMITED_MAPS
{"Google Street Map", UrlFactory::GoogleMap}, {"Google Street Map", UrlFactory::GoogleMap},
{"Google Satellite Map", UrlFactory::GoogleSatellite}, {"Google Satellite Map", UrlFactory::GoogleSatellite},
{"Google Terrain Map", UrlFactory::GoogleTerrain}, {"Google Terrain Map", UrlFactory::GoogleTerrain},
#endif
{"Bing Street Map", UrlFactory::BingMap}, {"Bing Street Map", UrlFactory::BingMap},
{"Bing Satellite Map", UrlFactory::BingSatellite}, {"Bing Satellite Map", UrlFactory::BingSatellite},
{"Bing Hybrid Map", UrlFactory::BingHybrid}, {"Bing Hybrid Map", UrlFactory::BingHybrid},
......
...@@ -33,20 +33,24 @@ ...@@ -33,20 +33,24 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UrlFactory::UrlFactory() UrlFactory::UrlFactory()
: _timeout(5 * 1000) : _timeout(5 * 1000)
#ifndef QGC_NO_GOOGLE_MAPS
, _googleVersionRetrieved(false) , _googleVersionRetrieved(false)
, _googleReply(NULL) , _googleReply(NULL)
#endif
{ {
QStringList langs = QLocale::system().uiLanguages(); QStringList langs = QLocale::system().uiLanguages();
if (langs.length() > 0) { if (langs.length() > 0) {
_language = langs[0]; _language = langs[0];
} }
#ifndef QGC_NO_GOOGLE_MAPS
// Google version strings // Google version strings
_versionGoogleMap = "m@338000000"; _versionGoogleMap = "m@338000000";
_versionGoogleSatellite = "198"; _versionGoogleSatellite = "198";
_versionGoogleLabels = "h@336"; _versionGoogleLabels = "h@336";
_versionGoogleTerrain = "t@132,r@338000000"; _versionGoogleTerrain = "t@132,r@338000000";
_secGoogleWord = "Galileo"; _secGoogleWord = "Galileo";
#endif
// BingMaps // BingMaps
_versionBingMaps = "563"; _versionBingMaps = "563";
} }
...@@ -54,8 +58,10 @@ UrlFactory::UrlFactory() ...@@ -54,8 +58,10 @@ UrlFactory::UrlFactory()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
UrlFactory::~UrlFactory() UrlFactory::~UrlFactory()
{ {
#ifndef QGC_NO_GOOGLE_MAPS
if(_googleReply) if(_googleReply)
_googleReply->deleteLater(); _googleReply->deleteLater();
#endif
} }
...@@ -123,6 +129,7 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag ...@@ -123,6 +129,7 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag
request.setRawHeader("Accept", "*/*"); request.setRawHeader("Accept", "*/*");
request.setRawHeader("User-Agent", _userAgent); request.setRawHeader("User-Agent", _userAgent);
switch (type) { switch (type) {
#ifndef QGC_NO_GOOGLE_MAPS
case GoogleMap: case GoogleMap:
case GoogleSatellite: case GoogleSatellite:
case GoogleLabels: case GoogleLabels:
...@@ -130,6 +137,7 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag ...@@ -130,6 +137,7 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag
case GoogleHybrid: case GoogleHybrid:
request.setRawHeader("Referrer", "https://www.google.com/maps/preview"); request.setRawHeader("Referrer", "https://www.google.com/maps/preview");
break; break;
#endif
case BingHybrid: case BingHybrid:
case BingMap: case BingMap:
case BingSatellite: case BingSatellite:
...@@ -152,6 +160,7 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag ...@@ -152,6 +160,7 @@ UrlFactory::getTileURL(MapType type, int x, int y, int zoom, QNetworkAccessManag
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef QGC_NO_GOOGLE_MAPS
void void
UrlFactory::_getSecGoogleWords(int x, int y, QString &sec1, QString &sec2) UrlFactory::_getSecGoogleWords(int x, int y, QString &sec1, QString &sec2)
{ {
...@@ -163,12 +172,16 @@ UrlFactory::_getSecGoogleWords(int x, int y, QString &sec1, QString &sec2) ...@@ -163,12 +172,16 @@ UrlFactory::_getSecGoogleWords(int x, int y, QString &sec1, QString &sec2)
sec1 = "&s="; sec1 = "&s=";
} }
} }
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QString QString
UrlFactory::_getURL(MapType type, int x, int y, int zoom, QNetworkAccessManager* networkManager) UrlFactory::_getURL(MapType type, int x, int y, int zoom, QNetworkAccessManager* networkManager)
{ {
switch (type) { switch (type) {
#ifdef QGC_NO_GOOGLE_MAPS
Q_UNUSED(networkManager);
#else
case GoogleMap: case GoogleMap:
{ {
// http://mt1.google.com/vt/lyrs=m // http://mt1.google.com/vt/lyrs=m
...@@ -215,6 +228,7 @@ UrlFactory::_getURL(MapType type, int x, int y, int zoom, QNetworkAccessManager* ...@@ -215,6 +228,7 @@ UrlFactory::_getURL(MapType type, int x, int y, int zoom, QNetworkAccessManager*
return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(x, y, 4)).arg(request).arg(_versionGoogleTerrain).arg(_language).arg(x).arg(sec1).arg(y).arg(zoom).arg(sec2); return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(x, y, 4)).arg(request).arg(_versionGoogleTerrain).arg(_language).arg(x).arg(sec1).arg(y).arg(zoom).arg(sec2);
} }
break; break;
#endif
/* /*
case OpenStreetMap: case OpenStreetMap:
{ {
...@@ -376,6 +390,7 @@ UrlFactory::_getServerNum(int x, int y, int max) ...@@ -376,6 +390,7 @@ UrlFactory::_getServerNum(int x, int y, int max)
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef QGC_NO_GOOGLE_MAPS
void void
UrlFactory::_networkReplyError(QNetworkReply::NetworkError error) UrlFactory::_networkReplyError(QNetworkReply::NetworkError error)
{ {
...@@ -386,15 +401,18 @@ UrlFactory::_networkReplyError(QNetworkReply::NetworkError error) ...@@ -386,15 +401,18 @@ UrlFactory::_networkReplyError(QNetworkReply::NetworkError error)
_googleReply = NULL; _googleReply = NULL;
} }
} }
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef QGC_NO_GOOGLE_MAPS
void void
UrlFactory::_replyDestroyed() UrlFactory::_replyDestroyed()
{ {
_googleReply = NULL; _googleReply = NULL;
} }
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef QGC_NO_GOOGLE_MAPS
void void
UrlFactory::_googleVersionCompleted() UrlFactory::_googleVersionCompleted()
{ {
...@@ -433,8 +451,10 @@ UrlFactory::_googleVersionCompleted() ...@@ -433,8 +451,10 @@ UrlFactory::_googleVersionCompleted()
_googleReply->deleteLater(); _googleReply->deleteLater();
_googleReply = NULL; _googleReply = NULL;
} }
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef QGC_NO_GOOGLE_MAPS
void void
UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager) UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager)
{ {
...@@ -466,6 +486,7 @@ UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager) ...@@ -466,6 +486,7 @@ UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager)
networkManager->setProxy(proxy); networkManager->setProxy(proxy);
} }
} }
#endif
#define AVERAGE_GOOGLE_STREET_MAP 4913 #define AVERAGE_GOOGLE_STREET_MAP 4913
#define AVERAGE_GOOGLE_TERRAIN_MAP 19391 #define AVERAGE_GOOGLE_TERRAIN_MAP 19391
......
...@@ -76,30 +76,38 @@ public: ...@@ -76,30 +76,38 @@ public:
static quint32 averageSizeForType (MapType type); static quint32 averageSizeForType (MapType type);
private slots: private slots:
#ifndef QGC_NO_GOOGLE_MAPS
void _networkReplyError (QNetworkReply::NetworkError error); void _networkReplyError (QNetworkReply::NetworkError error);
void _googleVersionCompleted (); void _googleVersionCompleted ();
void _replyDestroyed (); void _replyDestroyed ();
#endif
private: private:
QString _getURL (MapType type, int x, int y, int zoom, QNetworkAccessManager* networkManager); QString _getURL (MapType type, int x, int y, int zoom, QNetworkAccessManager* networkManager);
void _getSecGoogleWords (int x, int y, QString& sec1, QString& sec2); QString _tileXYToQuadKey (int tileX, int tileY, int levelOfDetail);
int _getServerNum (int x, int y, int max); int _getServerNum (int x, int y, int max);
#ifndef QGC_NO_GOOGLE_MAPS
void _getSecGoogleWords (int x, int y, QString& sec1, QString& sec2);
void _tryCorrectGoogleVersions (QNetworkAccessManager* networkManager); void _tryCorrectGoogleVersions (QNetworkAccessManager* networkManager);
QString _tileXYToQuadKey (int tileX, int tileY, int levelOfDetail); #endif
private:
int _timeout; int _timeout;
bool _googleVersionRetrieved;
QNetworkReply* _googleReply;
QMutex _googleVersionMutex;
QByteArray _userAgent; QByteArray _userAgent;
QString _language; QString _language;
// Google version strings // Google version strings
#ifndef QGC_NO_GOOGLE_MAPS
bool _googleVersionRetrieved;
QNetworkReply* _googleReply;
QMutex _googleVersionMutex;
QString _versionGoogleMap; QString _versionGoogleMap;
QString _versionGoogleSatellite; QString _versionGoogleSatellite;
QString _versionGoogleLabels; QString _versionGoogleLabels;
QString _versionGoogleTerrain; QString _versionGoogleTerrain;
QString _secGoogleWord; QString _secGoogleWord;
#endif
// BingMaps // BingMaps
QString _versionBingMaps; QString _versionBingMaps;
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include <QSet> #include <QSet>
#include <QDebug> #include <QDebug>
enum QGeoCodeTypeGoogle { enum QGCGeoCodeType {
GeoCodeTypeUnknown, GeoCodeTypeUnknown,
StreetAddress, // indicates a precise street address. StreetAddress, // indicates a precise street address.
Route, // indicates a named route (such as "US 101"). Route, // indicates a named route (such as "US 101").
...@@ -97,7 +97,7 @@ enum QGeoCodeTypeGoogle { ...@@ -97,7 +97,7 @@ enum QGeoCodeTypeGoogle {
class JasonMonger { class JasonMonger {
public: public:
JasonMonger(); JasonMonger();
QSet<int> json2QGeoCodeTypeGoogle(const QJsonArray &types); QSet<int> json2QGCGeoCodeType(const QJsonArray &types);
private: private:
int _getCode(const QString &key); int _getCode(const QString &key);
QMap<QString, int> _m; QMap<QString, int> _m;
...@@ -145,7 +145,7 @@ int JasonMonger::_getCode(const QString &key) { ...@@ -145,7 +145,7 @@ int JasonMonger::_getCode(const QString &key) {
return _m.value(key, GeoCodeTypeUnknown); return _m.value(key, GeoCodeTypeUnknown);
} }
QSet<int> JasonMonger::json2QGeoCodeTypeGoogle(const QJsonArray &types) { QSet<int> JasonMonger::json2QGCGeoCodeType(const QJsonArray &types) {
QSet<int> result; QSet<int> result;
for (int i=0; i<types.size(); ++i) { for (int i=0; i<types.size(); ++i) {
result |= _getCode(types[i].toString()); result |= _getCode(types[i].toString());
...@@ -228,7 +228,7 @@ void QGeoCodeReplyQGC::networkReplyFinished() ...@@ -228,7 +228,7 @@ void QGeoCodeReplyQGC::networkReplyFinished()
if (!c.contains(QStringLiteral("types"))) if (!c.contains(QStringLiteral("types")))
continue; continue;
QSet<int> types = kMonger.json2QGeoCodeTypeGoogle(c[QStringLiteral("types")].toArray()); QSet<int> types = kMonger.json2QGCGeoCodeType(c[QStringLiteral("types")].toArray());
QString long_name = c[QStringLiteral("long_name")].toString(); QString long_name = c[QStringLiteral("long_name")].toString();
QString short_name = c[QStringLiteral("short_name")].toString(); QString short_name = c[QStringLiteral("short_name")].toString();
if (types.contains(Country)) { if (types.contains(Country)) {
......
...@@ -95,9 +95,12 @@ QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVarian ...@@ -95,9 +95,12 @@ QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVarian
// Changes here must reflect those in QGCMapEngine.cpp // Changes here must reflect those in QGCMapEngine.cpp
QList<QGeoMapType> mapTypes; QList<QGeoMapType> mapTypes;
#ifndef QGC_NO_GOOGLE_MAPS
mapTypes << QGeoMapType(QGeoMapType::StreetMap, "Google Street Map", "Google street map", false, false, UrlFactory::GoogleMap); mapTypes << QGeoMapType(QGeoMapType::StreetMap, "Google Street Map", "Google street map", false, false, UrlFactory::GoogleMap);
mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, "Google Satellite Map", "Google satellite map", false, false, UrlFactory::GoogleSatellite); mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, "Google Satellite Map", "Google satellite map", false, false, UrlFactory::GoogleSatellite);
mapTypes << QGeoMapType(QGeoMapType::TerrainMap, "Google Terrain Map", "Google terrain map", false, false, UrlFactory::GoogleTerrain); mapTypes << QGeoMapType(QGeoMapType::TerrainMap, "Google Terrain Map", "Google terrain map", false, false, UrlFactory::GoogleTerrain);
#endif
/* TODO: /* TODO:
* Proper google hybrid maps requires collecting two separate bimaps and overlaying them. * Proper google hybrid maps requires collecting two separate bimaps and overlaying them.
...@@ -116,8 +119,10 @@ QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVarian ...@@ -116,8 +119,10 @@ QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVarian
*/ */
// MapQuest // MapQuest
/*
mapTypes << QGeoMapType(QGeoMapType::StreetMap, "MapQuest Street Map", "MapQuest street map", false, false, UrlFactory::MapQuestMap); mapTypes << QGeoMapType(QGeoMapType::StreetMap, "MapQuest Street Map", "MapQuest street map", false, false, UrlFactory::MapQuestMap);
mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, "MapQuest Satellite Map", "MapQuest satellite map", false, false, UrlFactory::MapQuestSat); mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, "MapQuest Satellite Map", "MapQuest satellite map", false, false, UrlFactory::MapQuestSat);
*/
/* /*
* These are OK as you need your own token for accessing it. Out-of-the box, QGC does not even offer these unless you enter a proper MapBox token. * These are OK as you need your own token for accessing it. Out-of-the box, QGC does not even offer these unless you enter a proper MapBox token.
......
...@@ -280,7 +280,15 @@ QGCView { ...@@ -280,7 +280,15 @@ QGCView {
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Map Providers //-- Map Providers
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth
/*
TODO: Map settings should come from QGroundControl.mapEngineManager. What is currently in
QGroundControl.flightMapSettings should be moved there so all map related funtions are in
one place.
*/
spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.flightMapSettings.googleMapEnabled
QGCLabel { QGCLabel {
id: mapProvidersLabel id: mapProvidersLabel
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment