如何在 QML (Qt) 中离线运行 OpenStreetMap [英] How to run OpenStreetMap offline in QML (Qt)

查看:147
本文介绍了如何在 QML (Qt) 中离线运行 OpenStreetMap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Qt 上使用 QML 来显示 OpenStreetMap(使用 osm 插件),这需要互联网连接.有没有办法可以做同样的事情但离线运行它?例如,运行我自己的磁贴服务器(但这样做有多容易)?或者使用可以让我很快完成的库.

I am using QML on Qt to display OpenStreetMap (using the osm plugin), which requires internet connection. Is there a way that I can do the same but running it offline? For example, running my own tile server (but how easy is that to do)? Or using a library that will let me do it quite quickly.

顺便说一下,我在 Ubuntu 上运行我的程序.

By the way I am running my program on Ubuntu.

任何有关如何做到这一点的帮助,特别是如果有人可以提供要完成的步骤,我们将不胜感激.

Any help on how to do that and especially if someone can provide the steps to be done would be appreciated.

谢谢.

推荐答案

我已经按照以下步骤在 Qt(使用 QML)中离线显示 OpenStreetMap:

I have managed to display OpenStreetMap offline in Qt (using QML) following the steps below:

  1. 在本地主机上构建/运行磁贴服务器.我使用了以下指南:https://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/
  2. 在 Qt 中的 map.qml 文件中,我必须在地图插件中包含以下参数 (http://doc.qt.io/qt-5/location-plugin-osm.html):

Plugin {
   id: osmMapPlugin
   name: "osm"

   //provide the address of the tile server to the plugin
   PluginParameter {
      name: "osm.mapping.custom.host"
      value: "http://localhost/osm/"
   }

   /*disable retrieval of the providers information from the remote repository. 
   If this parameter is not set to true (as shown here), then while offline, 
   network errors will be generated at run time*/
   PluginParameter {
      name: "osm.mapping.providersrepository.disabled"
      value: true
   }
}

  • 最后,Map QML 类型的 activeMapType 属性必须设置为 MapType.CustomMap (http://doc.qt.io/qt-5/qml-qtlocation-maptype.html) 使地图与本地切片服务器配合使用.

  • Finally, the activeMapType property of the Map QML type has to be set to MapType.CustomMap (http://doc.qt.io/qt-5/qml-qtlocation-maptype.html) for the map to work with the local tile server.

    这篇关于如何在 QML (Qt) 中离线运行 OpenStreetMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆