QML Map plugin "itemsoverlay" does not clip to the base map for large zoom, using visibleRegion()

505 views Asked by At

I have a somehow minimal example of a QML map (OSM plugin) and a respective map overlay with plugin itemsoverlay. The following code will clip the overlay to the map, no matter what movement or zoom the map undergoes.

However, I can zoom the base map closer than the maximum OSM zoom level (resulting in some zoom level 21.07), e.g. by using mapBase.visibleRegion = rect (see below). But the overlay will not zoom closer than this, the zoom will stay at level 19.

You can test this by clicking on the red circle.

Any Idea how to have the overlay still have the same zoom level as the base map?

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)
                }
            }
        }
    }
}
1

There are 1 answers

0
DomTomCat On

I was playing with some parameters and found a fix by chance: replace the

Map {
    id: map
    // ...
    maximumZoomLevel: mapBase.maximumZoomLevel
    // ...
}

to

Map {
    id: map
    // ...
    maximumZoomLevel: 30
    // ...
}

However, I do not understand why the latter works in contrast to the former and if it is even just a bug?