Как получить координаты при нажатии на карту в Qt Android
Я использую qt 5.14.1. Когда я нажимаю на экран, я получаю координаты карты после двух нажатий на экран. Для первого и второго касаний значение координаты не получено. После двух и трех касаний следующий график координат рядом с первой или второй координатой, независимо от места касания. Я использую следующий код
Map {
id: mapOfWorld
anchors.centerIn: parent;
anchors.fill: parent
activeMapType: supportedMapTypes[1];
gesture.enabled: true
gesture.acceptedGestures: MapGestureArea.PanGesture
plugin: hereMaps
MouseArea {
id: mapAreaClick
focus: true
anchors.rightMargin: 470
transformOrigin: Item.Center
anchors.horizontalCenterOffset: -1
anchors.fill: mapOfWorld
anchors.centerIn: mapOfWorld
propagateComposedEvents : true
preventStealing : true
hoverEnabled: true
drag.axis: Drag.XandYAxis
drag.target: mapOfWorld
onReleased: {
console.log("MouseArea onReleased")
}
onPositionChanged: {
mapOfWorld.pan(lastX-mouse.x, lastY-mouse.y)
lastX = mouse.x
lastY = mouse.y
}
// move or drag map
onPressAndHold: {
mapAreaClick.enabled = false
mapOfWorld.center = mapOfWorld.toCoordinate((Qt.point((mouse.x),(mouse.y))))
console.log("MouseArea onPressAndHold")
}
// plot the waypoint
onPressed: {
mapOfWorld.focus = true
mapAreaClick.enabled = true
var cordinate = mapOfWorld.toCoordinate((Qt.point((mouse.x),(mouse.y))));
Geofence.addGeoFenceAsset(cordinate)
}
}
}