0
votes

I'm new to Qt and i'm starting a new GUI using QML. I have a map and i want to display a marker. But i'm not able to display the marker using a MapQuickItem.
In my code below the title, the map and the MapCircle are displayed correctly, but the MapQuickItem is not displayed.
The image "marker.png" exists and i'm able to display it. Thanks for your help.

import QtQuick 2.0
import QtLocation 5.6
import QtPositioning 5.6
import "../items"
SimpleTile {
    m_width : 300
    m_height : 300
    property double m_latitude;
    property double m_longitude;

    innerObject: Column {
        id: colMap
        anchors.fill: parent

        Plugin {
            id: mapPlugin
            name: "esri"
        }

        Text {
            id: title
            width: colMap.width
            height: 25
            horizontalAlignment: TextInput.AlignHCenter
            font.bold: true
            font.pointSize: 15
            text: "Position"
        }
        Map {
            id: map
            width: colMap.width
            height: parent.height - title.height
            plugin: mapPlugin
            center: QtPositioning.coordinate(m_latitude, m_longitude)
            zoomLevel: 14

            MapQuickItem {
                id: marker
                anchorPoint.x: image.width/2
                anchorPoint.y: image.height

                coordinate {
                    latitude: m_latitude
                    longitude: m_longitude
                }
                sourceItem: Image { id: image; source: "qrc:/images/marker.png" }
            }
            MapCircle {
                radius: 1000
                color: "red"
                opacity: 0.4
                center {
                    latitude: m_latitude
                    longitude: m_longitude
                }
            }
        }
    }
}
1
Ok, if I want to test the code what should I do with SimpleTile etc? Please provide mvce, use image placeholder, for example this one so we can run and test the code.folibis
Sorry, basically SimpleTile is a 'Rectangle' (use to uniform l&f). All these Rectangle are added in a 'Flow'Fabrice
I think i have found the error, but I'm not able to test for the moment. I have changed: <pre> MapQuickItem { id: marker anchorPoint.x: image.width/2 anchorPoint.y: image.height coordinate : QtPositioning.coordinate(m_latitude, m_longitude) sourceItem: Image { id: image; source: "qrc:/images/marker.png" } }</pre>Fabrice
If you want us to help you, you must provide a minimal reproducible exampleeyllanesc

1 Answers

1
votes

Ok, I solve my problem by changing

...
 MapQuickItem {
...
                coordinate {
                    latitude: m_latitude
                    longitude: m_longitude
                }
...

to

...
 MapQuickItem {
...
                coordinate: QtPositioning.coordinate(m_latitude, m_longitude)
...

Thanks for your answers.