本页内容

Qt Location 项目叠加插件

概述

此地理服务插件是一个仅提供空白地图的特殊插件。该插件不提供任何服务,旨在用于那些需要让 `Map ` 元素仅显示已添加地图项的情况。

可通过插件键“itemsoverlay”加载“项目叠加”地理服务插件。

使用示例

以下代码片段演示了如何将使用此插件的地图作为叠加层添加,以显示经过抗锯齿处理的地图项。请注意,要使此类叠加层地图具有透明效果,还需将其颜色设置为透明色(如示例中的“transparent”)。

Window {
    id: win
    visible: true
    width: 640
    height: 640

    Map {
        id: mapBase
        anchors.fill: parent
        plugin: Plugin { name: "osm" }
        center: QtPositioning.coordinate(45,10)
        zoomLevel: 4
        z: parent.z + 1
    }

    Map {
        id: mapOverlay
        anchors.fill: parent
        plugin: Plugin { name: "itemsoverlay" }
        center: mapBase.center
        color: 'transparent' // Necessary to make this map transparent
        minimumFieldOfView: mapBase.minimumFieldOfView
        maximumFieldOfView: mapBase.maximumFieldOfView
        minimumTilt: mapBase.minimumTilt
        maximumTilt: mapBase.maximumTilt
        minimumZoomLevel: mapBase.minimumZoomLevel
        maximumZoomLevel: mapBase.maximumZoomLevel
        zoomLevel: mapBase.zoomLevel
        tilt: mapBase.tilt;
        bearing: mapBase.bearing
        fieldOfView: mapBase.fieldOfView
        z: mapBase.z + 1

        MapCircle {
            id: circle
            center: QtPositioning.coordinate(44, 10)
            radius: 200000
            border.width: 5

            MouseArea {
                anchors.fill: parent
                drag.target: parent
            }
        }

        // The code below enables SSAA
        layer.enabled: true
        layer.smooth: true
        property int w : mapOverlay.width
        property int h : mapOverlay.height
        property int pr: Screen.devicePixelRatio
        layer.textureSize: Qt.size(w  * 2 * pr, h * 2 * pr)
    }
}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.