首页 > 解决方案 > QML 地图调试

问题描述

我对minimum_map演示做了一些小的修改,以允许它使用离线图块。它在我的桌面上完美运行,但是当我在嵌入式目标上运行它时,它只加载一个空白的灰色屏幕。我假设我可能缺少嵌入式目标上的必需组件。它具有 QLocaiton 模块以及 OSM 插件。我得到的唯一错误信息qrc:/main.qml:87:24: Unable to assign [undefined] to QDeclarativeGeoMapType*来自这一行activeMapType: supportedMapTypes[supportedMapTypes.length - 1]。这是因为在嵌入式目标上,supportedMapTypes.length返回 0。有人可以推荐一些关于如何调试它的想法。仅此错误消息很难。

import QtQuick 2.0
import QtQuick.Window 2.0
import QtLocation 5.6
import QtPositioning 5.6

Window {
    width: 800
    height: 480
    visible: true

    Plugin {
        id: mapPlugin
        name: "osm"

        PluginParameter {
            name: "osm.mapping.custom.host"
            value: "file:///usr/bin/resources/maptiles/"
        }
        PluginParameter {
            name: "osm.mapping.providersrepository.disabled"
            value: true
        }
        PluginParameter {
            name: "osm.mapping.cache.directory"
            value: "/home/asdf/Documents/cache"
        }

        Component.onCompleted: {
            console.log("Plugin loaded")
        }
    }

    Map {
        anchors.fill: parent
        plugin: mapPlugin
        zoomLevel: 7
        activeMapType: supportedMapTypes[supportedMapTypes.length - 1]

        Component.onCompleted: {
            for( var i = 0; i < supportedMapTypes.length; i++) {
                console.log(supportedMapTypes[i].name)
            }

            console.log("Map loaded")
        }
    }
}

标签: qtqml

解决方案


推荐阅读