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