首页 > 其他分享 >QGC添加在线地图

QGC添加在线地图

时间:2022-10-09 00:22:32浏览次数:48  
标签:在线 URL 地图 mapTypes 枚举 添加 arg QGC

一、概述

QGC版本:qgroundcontrol-3.4.0。

        在线地图添加分为两部分:

        1.QGC的Application Setting页面的General的设置页面,MapProvider和MapType的类型的添加,这里只添加的是按钮选项。

        2.添加QGC实际瓦片地图的url路径。

二、具体操作

        UI选项界面的选择项添加具体操作:

1.在js文件FlightMap.SettingsGroup.json(path:src\Settings\FlightMap.SettingsGroup.json)中添加MapProvider和MapType的类型。

//js文件FlightMap.SettingsGroup.json源码
[ { "name": "MapProvider", "shortDescription": "Currently selected map provider for flight maps", "type": "uint32", "enumStrings": "Bing,Google,Statkart,Mapbox,Esri,Eniro,Gaode,Tianditu",  //MapProvider枚举值,将要添加的地图名字加到这里 "enumValues": "0,1,2,3,4,5,6,7",        //这里的数要和上面的enumValues数量对应起来,上后面加后这里得加数字。 "defaultValue": 0 }, { "name": "MapType", "shortDescription": "Currently selected map type for flight maps", "type": "uint32", "enumStrings": "Street Map,Satellite Map,Hybrid Map,Terrain Map",    //MapType枚举值,将要添加的地图类型添加到这里 "enumValues": "0,1,2,3",                //这里的数要和上面的enumValues数量对应起来,上后面加后这里得加数字。
"defaultValue": 2 
}
]

 

        添加提供地图URL的具体操作:

1.在QGCMapUrlEngine.h文件中添加URL类型的枚举值

class UrlFactory : public QObject {
    Q_OBJECT
public:

    enum MapType
    {
        Invalid                 = -1,

        GoogleMap               = 1,
        GoogleSatellite         = 4,
        GoogleLabels            = 8,
        GoogleTerrain           = 16,
        GoogleHybrid            = 20,
    //URL枚举值名字 枚举值(随意,只要不重复即可)
    .
    .
    .
    .
  ......

 

2.在QGeoTiledMappingManagerEngineQGC.cpp的QList<QGeoMapType> mapTypes列表中添加地图成员(地图名字,url对应信息数组)

    mapTypes << QGCGEOMAPTYPE(QGeoMapType::StreetMap,         "Google Street Map",        "Google street map",            false,  false,  UrlFactory::GoogleMap);
    mapTypes << QGCGEOMAPTYPE(QGeoMapType::SatelliteMapDay,   "Google Satellite Map",     "Google satellite map",         false,  false,  UrlFactory::GoogleSatellite);
    mapTypes << QGCGEOMAPTYPE(QGeoMapType::TerrainMap,        "Google Terrain Map",       "Google terrain map",           false,  false,  UrlFactory::GoogleTerrain);
#endif

    /* TODO:
     *  Proper google hybrid maps requires collecting two separate bitmaps and overlaying them.
     *
     * mapTypes << QGCGEOMAPTYPE(QGeoMapType::HybridMap,       "Google Hybrid Map",        "Google hybrid map",            false, false, UrlFactory::GoogleHybrid);
     *
     */

    // Bing
    mapTypes << QGCGEOMAPTYPE(QGeoMapType::StreetMap,         "Bing Street Map",          "Bing street map",                  false,  false,  UrlFactory::BingMap);
    mapTypes << QGCGEOMAPTYPE(QGeoMapType::SatelliteMapDay,   "Bing Satellite Map",       "Bing satellite map",               false,  false,  UrlFactory::BingSatellite);
    mapTypes << QGCGEOMAPTYPE(QGeoMapType::HybridMap,         "Bing Hybrid Map",          "Bing hybrid map",                  false,  false,  UrlFactory::BingHybrid);
  .
  .
  .
  .
  .
  .
// Gaode
    //
"Gaode Street Map":地图名字+空格+地图类型(这里名字和类型要和js文件FlighMap。SettingGroup.json中对应起来
      //UrlFactory::GaodeStreet:要和QGCMapUrlEngine.h中的URL枚举值名字对应起来
mapTypes << QGCGEOMAPTYPE(QGeoMapType::StreetMap, "Gaode Street Map", "Gaode street map", false, false, UrlFactory::GaodeStreet); 
mapTypes << QGCGEOMAPTYPE(QGeoMapType::SatelliteMapDay, "Gaode Satellite Map", "Gaode satellite map", false, false, UrlFactory::GaodeSatellite);
mapTypes << QGCGEOMAPTYPE(QGeoMapType::HybridMap, "Gaode Hybrid Map", "Gaode hybrid map", false, false, UrlFactory::GaodeHybrid);
//Tianditu mapTypes << QGCGEOMAPTYPE(QGeoMapType::StreetMap, "Tianditu Street Map", "Tianditu street map", false, false, UrlFactory::TiandituStreet);
mapTypes << QGCGEOMAPTYPE(QGeoMapType::SatelliteMapDay, "Tianditu Satellite Map", "Tianditu satellite map", false, false, UrlFactory::TiandituSatellite);
mapTypes << QGCGEOMAPTYPE(QGeoMapType::HybridMap, "Tianditu Hybrid Map", "Tianditu hybrid map", false, false, UrlFactory::TiandituHybrid);
mapTypes << QGCGEOMAPTYPE(QGeoMapType::TerrainMap, "Tianditu Terrain Map", "Tianditu Terrain Base", false, false, UrlFactory::TiandituTerrain);
setSupportedMapTypes(mapTypes);

 

3.在QGCMapUrlEngine.cpp文件中添加瓦片地图URL,

在UrlFactory::_getURL(MapType type, int x, int y, int zoom, QNetworkAccessManager* networkManager)函数中添加URL
 case GaodeSatellite:  //地图名字和QGCMapUrlEngine.h中枚举值对应
    {
        return QString("http://wprd01.is.autonavi.com/appmaptile?x=%1&y=%2&z=%3&lang=zh_cn&size=1&scl=1&style=6").arg(x).arg(y).arg(zoom);
      //高德卫星影像瓦片地图URL } break; case GaodeStreet: { return QString("http://wprd01.is.autonavi.com/appmaptile?x=%1&y=%2&z=%3&lang=zh_cn&size=1&scl=1&style=7").arg(x).arg(y).arg(zoom); } break;

 



 

标签:在线,URL,地图,mapTypes,枚举,添加,arg,QGC
From: https://www.cnblogs.com/tgc-3/p/16770746.html

相关文章