我正在使用 Qt Creator(社区)5.5.1 制作项目并支持 QML。我有这个代码:
主.qml:
MouseArea
{ anchors.fill: parent
onPressed: console.log('latitude = '+ (map.toCoordinate(Qt.point(mouse.x,mouse.y)).latitude),
'longitude = '+ (map.toCoordinate(Qt.point(mouse.x,mouse.y)).longitude));
Run Code Online (Sandbox Code Playgroud)
所以当我点击屏幕时,地图上这个地方的坐标会显示在控制台上。但我不知道如何使用这些坐标在发生点击的屏幕上定位标记。这是标记代码:
MapQuickItem {
id:marker
coordinate: QtPositioning.coordinate(******, ******);//stars are the coordinates
sourceItem: Image{
id: image
source: "marker2.png"
}
anchorPoint.x: image.width / 2
anchorPoint.y: image.height
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能将标记定位在地图上发生点击的坐标处?谢谢。