我是一位有用的助手,可以为您翻译文本。
我正在使用支持QML的Qt Creator(Community)5.5.1制作项目。 我有以下代码:
main.qml:
我正在使用支持QML的Qt Creator(Community)5.5.1制作项目。 我有以下代码:
main.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));
当我点击屏幕时,这个地方在地图上的坐标会显示在控制台上。但我不知道如何使用这些坐标将标记放置在发生点击的屏幕位置上。这是标记代码:
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
}
我应该怎么做才能将标记放置在点击发生的坐标位置上?谢谢。