• 大小: 32KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-07-13
  • 语言: C/C++
  • 标签: 无人机  地面站  qt  c++  

资源简介

一款基于qt的c++2d地图库,支持的地图大概有二十多种,包括雅虎,谷歌,OpenStreetMap,bing,ArcGIS等,不过有的需要..,你懂的

资源截图

代码片段和文件信息

#include “qgeocodereplygooglemaps.h“


#include 
#include 
#include 
#include 

#include 
#include 
#include ject>
#include “QDebug“

static QGeoCoordinate constructCoordiante(const QJsonobject &jsonCoord) {
    QGeoCoordinate coord(00);
    coord.setLatitude(jsonCoord.value(QStringLiteral(“lat“)).toDouble());
    coord.setLongitude(jsonCoord.value(QStringLiteral(“lng“)).toDouble());
    return coord;
}

static bool checkAddressType(const QJsonobject &jsonAddress const QString &type) {
    QJsonArray a = jsonAddress.value(“types“).toArray();
    for (int i = 0; i < a.size(); i++) {
        if (a.at(i).toString() == type)
            return true;
    }
    return false;
}

QGeoCodeReplyGooglemaps::QGeoCodeReplyGooglemaps(QNetworkReply *reply Qobject *parent)
    :   QGeoCodeReply(parent) m_reply(reply)
{
    connect(m_reply SIGNAL(finished()) this SLOT(networkReplyFinished()));
    connect(m_reply SIGNAL(error(QNetworkReply::NetworkError))
            this SLOT(networkReplyError(QNetworkReply::NetworkError)));

    setLimit(1);
    setOffset(0);
}

QGeoCodeReplyGooglemaps::~QGeoCodeReplyGooglemaps()
{
    if (m_reply)
        m_reply->deleteLater();
}

void QGeoCodeReplyGooglemaps::abort()
{
    if (!m_reply)
        return;

    m_reply->abort();

    m_reply->deleteLater();
    m_reply = 0;
}


void QGeoCodeReplyGooglemaps::networkReplyFinished()
{
    if (!m_reply)
        return;

    if (m_reply->error() != QNetworkReply::NoError)
        return;

    QString status;

    QList locations;
    //        setError(QGeoCodeReply::ParseError QStringLiteral(“Error parsing OpenRouteService xml response:“) + xml.errorString() + “ at line: “ + xml.lineNumber());
    QJsonDocument document = QJsonDocument::fromJson(m_reply->read(m_reply->bytesAvailable()));
    if (document.isobject()) {
        QJsonobject object = document.object();

        status = object.value(QStringLiteral(“status“)).toString();
        if (status == “OK“) {
            QJsonArray jsonlocations = object.value(QStringLiteral(“results“)).toArray();
            qDebug() << “locations:“ << jsonlocations.size();
            for(int i = 0; i < jsonlocations.size(); i++) {
                QGeoLocation location;
                QGeoAddress address;

                QJsonobject o = jsonlocations.at(i).toobject();
                address.setText(o.value(“formatted_address“).toString());
                QJsonobject ogeometry = o.value(“geometry“).toobject();

                location.setCoordinate(constructCoordiante(ogeometry.value(“location“).toobject()));

                QJsonobject jaddressRanges = ogeometry.value(“viewport“).toobject();
                if (!jaddressRanges.isEmpty()) {
                   

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-02 10:44  googlemaps-master\
     文件         563  2018-06-02 10:44  googlemaps-master\.gitignore
     文件          46  2018-06-02 10:44  googlemaps-master\.qmake.conf
     文件        1104  2018-06-02 10:44  googlemaps-master\LICENSE.txt
     文件          80  2018-06-02 10:44  googlemaps-master\README.md
     文件        1675  2018-06-02 10:44  googlemaps-master\googlemaps.pro
     文件         337  2018-06-02 10:44  googlemaps-master\googlemaps_plugin.json
     文件        6166  2018-06-02 10:44  googlemaps-master\qgeocodereplygooglemaps.cpp
     文件         535  2018-06-02 10:44  googlemaps-master\qgeocodereplygooglemaps.h
     文件        4988  2018-06-02 10:44  googlemaps-master\qgeocodingmanagerenginegooglemaps.cpp
     文件        1260  2018-06-02 10:44  googlemaps-master\qgeocodingmanagerenginegooglemaps.h
     文件        2954  2018-06-02 10:44  googlemaps-master\qgeoerror_messages.cpp
     文件        2318  2018-06-02 10:44  googlemaps-master\qgeoerror_messages.h
     文件        1482  2018-06-02 10:44  googlemaps-master\qgeomapreplygooglemaps.cpp
     文件         698  2018-06-02 10:44  googlemaps-master\qgeomapreplygooglemaps.h
     文件        8558  2018-06-02 10:44  googlemaps-master\qgeoroutereplygooglemaps.cpp
     文件         668  2018-06-02 10:44  googlemaps-master\qgeoroutereplygooglemaps.h
     文件        5497  2018-06-02 10:44  googlemaps-master\qgeoroutingmanagerenginegooglemaps.cpp
     文件         923  2018-06-02 10:44  googlemaps-master\qgeoroutingmanagerenginegooglemaps.h
     文件        1366  2018-06-02 10:44  googlemaps-master\qgeoserviceproviderplugingooglemaps.cpp
     文件        1515  2018-06-02 10:44  googlemaps-master\qgeoserviceproviderplugingooglemaps.h
     文件         928  2018-06-02 10:44  googlemaps-master\qgeotiledmapgooglemaps.cpp
     文件         780  2018-06-02 10:44  googlemaps-master\qgeotiledmapgooglemaps.h
     文件        4415  2018-06-02 10:44  googlemaps-master\qgeotiledmappingmanagerenginegooglemaps.cpp
     文件        1073  2018-06-02 10:44  googlemaps-master\qgeotiledmappingmanagerenginegooglemaps.h
     文件        7607  2018-06-02 10:44  googlemaps-master\qgeotilefetchergooglemaps.cpp
     文件        1819  2018-06-02 10:44  googlemaps-master\qgeotilefetchergooglemaps.h
     文件         532  2018-06-02 10:44  googlemaps-master\qplacecategoriesreplygooglemaps.cpp
     文件         461  2018-06-02 10:44  googlemaps-master\qplacecategoriesreplygooglemaps.h
     文件       16027  2018-06-02 10:44  googlemaps-master\qplacemanagerenginegooglemaps.cpp
     文件        1966  2018-06-02 10:44  googlemaps-master\qplacemanagerenginegooglemaps.h
............此处省略4个文件信息

评论

共有 条评论