qtqmlqtlocation

Qt Map not Resizing Correctly


Using Qt 5.15.14 - QtLocation 5.15 - QtPositioning 5.15

I have a map anchored to the left side of my ApplicationWindow. When the window is resized to a smaller height, the map correctly adheres to its anchor points. However, when the window is expanded, the map does not display properly.

How should I fix this? Here's the Map code.

Map {
    id: map

    property real mapRadius: 25

    readonly property real minZoom: 6.0
    readonly property real maxZoom: 17.0

    readonly property var centerCoordinates: QtPositioning.coordinate(41.9027835, 12.4963655)
    
    width: 500
    height: 500

    minimumZoomLevel: map.minZoom
    maximumZoomLevel: map.maxZoom

    center: map.centerCoordinates
    zoomLevel: (map.minZoom+map.maxZoom)/2

    plugin: Plugin {
        name: "osm"
        PluginParameter { name: "osm.mapping.highdpi_tiles"; value: "true" }
    }

    ...
}

And here's the Map declaration

GSMap {
    id: gasStationMap

    width: height

    anchors {
        top: parent.top; topMargin: 20
        bottom: parent.bottom; bottomMargin: 20
        left: parent.left; leftMargin: 20
    }
}

And this is what I see after the resize: Map Screen

Thanks! :)


Solution

  • It sounds crazy... but not relating the map's width to its height was sufficent to make that gray strip disappear!

    GSMap {
        id: gasStationMap
    
        width: parent.width*0.70
    
        anchors {
            top: parent.top; topMargin: 25
            bottom: parent.bottom; bottomMargin: 25
            left: parent.left; leftMargin: 25
        }
    }