|
| 1 | +#include "QtLocation/private/qgeocameracapabilities_p.h" |
| 2 | +#include "qgeotiledmappingmanagerenginegooglemaps.h" |
| 3 | +#include "qgeotiledmapgooglemaps.h" |
| 4 | +#include "qgeotilefetchergooglemaps.h" |
| 5 | +#include "QtLocation/private/qgeotilespec_p.h" |
| 6 | +#include "QtLocation/private/qgeofiletilecache_p.h" |
| 7 | + |
| 8 | +#include <QDebug> |
| 9 | +#include <QDir> |
| 10 | +#include <QVariant> |
| 11 | +#include <QtCore/QJsonArray> |
| 12 | +#include <QtCore/QJsonObject> |
| 13 | +#include <QtCore/QJsonDocument> |
| 14 | +#include <QtCore/qmath.h> |
| 15 | +#include <QtCore/qstandardpaths.h> |
| 16 | + |
| 17 | +QT_BEGIN_NAMESPACE |
| 18 | + |
| 19 | +QGeoTiledMappingManagerEngineGooglemaps::QGeoTiledMappingManagerEngineGooglemaps(const QVariantMap ¶meters, |
| 20 | + QGeoServiceProvider::Error *error, |
| 21 | + QString *errorString) |
| 22 | + : QGeoTiledMappingManagerEngine() |
| 23 | +{ |
| 24 | + Q_UNUSED(error); |
| 25 | + Q_UNUSED(errorString); |
| 26 | + |
| 27 | + QGeoCameraCapabilities capabilities; |
| 28 | + |
| 29 | + capabilities.setMinimumZoomLevel(0.0); |
| 30 | + capabilities.setMaximumZoomLevel(21.0); |
| 31 | + |
| 32 | + setCameraCapabilities(capabilities); |
| 33 | + |
| 34 | + setTileSize(QSize(256, 256)); |
| 35 | + |
| 36 | + QList<QGeoMapType> types; |
| 37 | + types << QGeoMapType(QGeoMapType::StreetMap, tr("Street Map"), tr("Normal map view in daylight mode"), false, false, 1); |
| 38 | + types << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Satellite Map"), tr("Satellite map view in daylight mode"), false, false, 2); |
| 39 | + types << QGeoMapType(QGeoMapType::TerrainMap, tr("Terrain Map"), tr("Terrain map view in daylight mode"), false, false, 3); |
| 40 | + types << QGeoMapType(QGeoMapType::HybridMap, tr("Hybrid Map"), tr("Satellite map view with streets in daylight mode"), false, false, 4); |
| 41 | + setSupportedMapTypes(types); |
| 42 | + |
| 43 | + QGeoTileFetcherGooglemaps *fetcher = new QGeoTileFetcherGooglemaps(parameters, this, tileSize()); |
| 44 | + setTileFetcher(fetcher); |
| 45 | + |
| 46 | + m_cacheDirectory = QAbstractGeoTileCache::baseCacheDirectory() + QLatin1String("googlemaps"); |
| 47 | + |
| 48 | + QAbstractGeoTileCache *tileCache = new QGeoFileTileCache(m_cacheDirectory); |
| 49 | + setTileCache(tileCache); |
| 50 | + |
| 51 | + populateMapSchemes(); |
| 52 | +} |
| 53 | + |
| 54 | +QGeoTiledMappingManagerEngineGooglemaps::~QGeoTiledMappingManagerEngineGooglemaps() |
| 55 | +{ |
| 56 | +} |
| 57 | + |
| 58 | +void QGeoTiledMappingManagerEngineGooglemaps::populateMapSchemes() |
| 59 | +{ |
| 60 | + m_mapSchemes[0] = QStringLiteral("roadmap"); |
| 61 | + m_mapSchemes[1] = QStringLiteral("roadmap"); |
| 62 | + m_mapSchemes[2] = QStringLiteral("satellite"); |
| 63 | + m_mapSchemes[3] = QStringLiteral("terrain"); |
| 64 | + m_mapSchemes[4] = QStringLiteral("hybrid"); |
| 65 | +} |
| 66 | + |
| 67 | +QString QGeoTiledMappingManagerEngineGooglemaps::getScheme(int mapId) |
| 68 | +{ |
| 69 | + return m_mapSchemes[mapId]; |
| 70 | +} |
| 71 | + |
| 72 | +QGeoMap *QGeoTiledMappingManagerEngineGooglemaps::createMap() |
| 73 | +{ |
| 74 | + return new QGeoTiledMapGooglemaps(this); |
| 75 | +} |
| 76 | + |
| 77 | +QT_END_NAMESPACE |
| 78 | + |
0 commit comments