【问题标题】:QML Custom Tile serverQML 自定义瓷砖服务器
【发布时间】:2021-08-08 07:52:23
【问题描述】:

我正在尝试使用我的机器托管的自定义服务器绘制离线地图。我已经按照这个project for 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]
}

}

【问题讨论】:

  • 你能告诉我你是怎么放地图的吗?表示包含地图的文件夹。你应该使用平铺地图。 (TMS)
  • @Parisa.H.R 没有文件夹。该地图位于 docker 卷内。码头工人运行一个服务器,并把我请求的瓷砖带给我。
  • docker如何获取地图?从哪里?有一次我使用 apache2 来做这样的事情。重要的是您的地图是 TMS。
  • 所以,有一个与docker绑定的文件夹。当前位置在路径中:/home/zambia-latest.osm.pbf
  • 不,应该是名称只有数字(1,2,3,..)的文件夹,这个数字显示地图的缩放级别,每个文件夹中都有 png 或 jpg 平铺地图。喜欢this question folder picture

标签: qt qml openstreetmap offline qtlocation


【解决方案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]
    }

}

输出:

【讨论】:

  • 这似乎有效。但是当我的应用程序尝试与服务器通信时仍然出现错误:{GeoTileRequestManager: Failed to fetch tile (2370,2224,12) 5 次,放弃。最后一条错误消息是:“传输 localhost/tile/12/2370/2224.png 时出错 - 服务器回复:未找到”}。 @eyllanesc,你有这个问题吗?
  • @MarioDeSantis 坐标似乎不是地图的一部分,因此您会收到该错误。在您的浏览器中打开链接并检查您获得的内容。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-28
  • 1970-01-01
  • 1970-01-01
  • 2012-05-26
相关资源
最近更新 更多