qt - QML 自定义瓷砖服务器
问题描述
我正在尝试使用我的机器托管的自定义服务器绘制离线地图。我已经按照 docker 这个项目的步骤进行操作。当我使用我的浏览器(http://localhost:8080/)时它可以工作。但是当我尝试使用下面的代码访问 QML 时,我只得到一个静态图像 GPS 输出
.
我究竟做错了什么?正如我在浏览器中看到的那样,我应该以良好的分辨率看到赞比亚。
QML 代码
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.VirtualKeyboard 2.4
import QtLocation 5.11
ApplicationWindow {
id: window
width: 640
height: 480
visible: true
title: qsTr("GPS")
Plugin{
id: plugin_osm
name: "osm"
PluginParameter {
name: "osm.mapping.custom.host"
value: "http://localhost:8080"
}
/*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 {
id: map
anchors.fill: parent
plugin: plugin_osm
zoomLevel: 12
minimumZoomLevel: 5
maximumZoomLevel: 17
center: QtPositioning.coordinate(54.2,16.2)
activeMapType: supportedMapTypes[supportedMapTypes.length - 1]
}
}
解决方案
您有 2 个错误:
- 楼主错了。
- 坐标不是赞比亚而是波兰
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtLocation 5.15
import QtPositioning 5.15
ApplicationWindow {
id: window
width: 640
height: 480
visible: true
title: qsTr("GPS")
Plugin {
id: plugin_osm
name: "osm"
PluginParameter {
name: "osm.mapping.custom.host"
value: "http://localhost/tile/"
}
/*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 {
id: map
anchors.fill: parent
plugin: plugin_osm
zoomLevel: 12
minimumZoomLevel: 5
maximumZoomLevel: 17
center: QtPositioning.coordinate(-15.4067, 28.2871)
activeMapType: supportedMapTypes[supportedMapTypes.length - 1]
}
}
输出:
推荐阅读
- c# - 在 PORT:80 之后更改 IIS 中的默认名称
- r - 使用 rsample 包的引导比使用引导包慢得多
- java - Spring Data Jpa EntityManager 刷新不起作用
- python - ModuleNotFoundError:没有名为“dota”的模块
- arrays - 试图从 json/api 而不是数组中提取数据
- reactjs - 页面中的 MUIDataTable 默认行不起作用
- gitlab - Gitlab-CI 又名管道依赖项中的上游触发
- amazon-web-services - AWS CloudWatch 自定义指标在实例类型更改后未显示
- azure - 将 Cosmbos DB Sql Api 中 Container 的主键命名为不同于“id”
- flutter - ios 中的音频显示错误的持续时间计时,但在 android 颤振应用程序中正确