QML 自定义磁贴服务器

QML Custom Tile server

我正在尝试使用我的机器托管的自定义服务器绘制离线地图。对于 docker,我已按照此 project 的步骤进行操作。当我使用我的浏览器 (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]
    }

}

输出: