我有一个 QML 地图(OSM 插件)和一个带有插件的相应地图覆盖的最小示例itemsoverlay
。无论地图进行何种移动或缩放,以下代码都会将叠加层剪辑到地图上。
但是,我可以将基本地图缩放得比最大 OSM 缩放级别更近(导致某些缩放级别 21.07),例如通过使用mapBase.visibleRegion = rect
(见下文)。但覆盖不会比这更近,缩放将保持在 19 级。
您可以通过单击红色圆圈进行测试。
任何想法如何让叠加层仍然具有与底图相同的缩放级别?
import QtQuick.Window 2.2
import QtQuick 2.7
import QtLocation 5.8
import QtPositioning 5.8
import QtQuick.Controls 2.2
Window {
width: 512
height: 512
visible: true
Map {
id: mapBase
anchors.fill: parent
gesture.enabled: true
plugin: Plugin { name: "osm" }
z: parent.z + 1
maximumZoomLevel: 30
center: QtPositioning.coordinate(51.51939, -0.11832)
Component.onCompleted: {
mapBase.zoomLevel = 19
}
}
Map {
id: map
anchors.fill: parent
plugin: Plugin { name: "itemsoverlay" }
gesture.enabled: false
center: mapBase.center
color: '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
// visibleRegion: mapBase.visibleRegion
anchors.centerIn: parent
MapCircle {
center: QtPositioning.coordinate(51.51939, -0.11832)
radius: 10
color: "red"
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
var rect = QtPositioning.rectangle(
QtPositioning.coordinate(51.51949, -0.11842),
QtPositioning.coordinate(51.51929, -0.11822))
mapBase.visibleRegion = rect
parent.color = 'green'
console.log(map.zoomLevel, mapBase.zoomLevel)
}
}
}
}
}