如何在QML(Qt)中离线运行OpenStreetMap

7
我正在使用Qt中的QML来显示OpenStreetMap(使用osm插件),这需要互联网连接。是否有一种方法可以离线运行相同的操作?例如,运行自己的瓦片服务器(但是这样做有多容易)?或者使用可以让我快速完成此操作的库。
顺便说一下,我在Ubuntu上运行我的程序。
如果有人能提供如何实现此操作的步骤,将不胜感激。
谢谢。

1
请查看ArcGIS Runtime SDK for Qt QML - folibis
1个回答

9
我已经成功地在Qt中(使用QML)离线显示了OpenStreetMap,具体步骤如下:

  1. Build/run a tile server on the localhost. I have used the following guide: https://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/
  2. On my map.qml file in Qt, I had to include the following parameters on the map plugin (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
       }
    }
    
  3. 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.


1
您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - Pa_

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接