一,安装 google Earth Plugin

Qt 调用 google Earth Plugin com 组件


二,将 earth 注册侧到系统中。为了 调用com 组件。

Qt 调用 google Earth Plugin com 组件


三,利用 Qt  dumpcpp.exe  生成接口文件 earthlib.h  和earthlib.cpp。这两个文件 涵盖了所有的接口。可以将 Qt的这个工具的路径 加到path的环境变量中。

Qt 调用 google Earth Plugin com 组件


四,将 earthlib.h  和earthlib.cpp 添加到自己的工程中。同时 工程当中 需要添加 CONFIG+=qaxcontainer  。使其支持 com组件 功能。

Qt 调用 google Earth Plugin com 组件Qt 调用 google Earth Plugin com 组件


五,添加 地图控件 窗口  到自己的窗口中

void Widget::init()
{
    CoInitialize(NULL);

    appGE = new ApplicationGE();
    renderOLE= appGE->GetRenderHwnd();
    mainOLE   = appGE->GetMainHwnd();

    renderParentHandle = GetParent((HWND)renderOLE);
    mainHandle = (HWND)(mainOLE);

    WId id = ui->openGLWidget->winId();
    SetParent(renderParentHandle, (HWND)id);
    ShowWindow(mainHandle, SW_HIDE);
    if (SUCCEEDED(appGE))
    {
        while (appGE->IsInitialized() == 0)
        {
            qDebug()<<QStringLiteral("已经登录");
            Sleep(500);
        }
    }

   qDebug()<<"isOnLine"<< appGE->IsOnline();
   appGE->Login();

   qDebug()<<"ver"<<appGE->VersionMajor()<<appGE->VersionMinor()<<appGE->VersionBuild();
}


添加退出 函数,析构时 执行,否则 google earth 会在后台 不退出。

void Widget::exit()
{
    // Close the main Google Earth app
    PostMessage(mainHandle, WM_QUIT, 0, 0);
    appGE->deleteLater();
}


六,google  earth api 可通过ApplicationGE  访问,比如下边的 相机切换

void Widget::on_lineEdit_editingFinished()
{
    appGE->SetCameraParams(32,118,0,RelativeToGroundAltitudeGE,45,0,4,2);
}


七,效果如下,目前扔 存在窗口 大小不对的问题。 源码路径:https://download.csdn.net/download/weixin_38416696/10278123

Qt 调用 google Earth Plugin com 组件


八,附 其他 大神博客, 关于com组件的介绍 和api简介

http://blog.csdn.net/Marcelxx/article/details/11472317

http://download.csdn.net/download/a105801209030/10262850

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
猜你喜欢
  • 2021-09-05
  • 2022-03-08
  • 2022-03-05
相关资源
相似解决方案