我想拖动一个在组件内部声明并从地图获取实时坐标的MapQuickItem。我能够成功拖动组件,但是我拖动MapQuickItem时,快速的鼠标光标离开了MapQuickItem,拖动被中断。如何在拖动时同步鼠标光标和MapQuickItem。
Map {
id: map
anchors.fill: parent
activeMapType: supportedMapTypes[1];
zoomLevel: 18
plugin: hereMaps
center: QtPositioning.coordinate(19.997454, 73.789803)
MapItemView {
id: markerItem
model: [
{ id: "marker1", color: "red" },
{ id: "marker2", color: "green" },
]
delegate: mapMarkerComponent
}
Component {
id : mapMarkerComponent
MapQuickItem {
id: mapMarker
coordinate: QtPositioning.coordinate(19.997454, 73.789803)
sourceItem: Rectangle {
id: handle
color: modelData.color
width: 40
height: 40
MouseArea {
drag.target: parent
anchors.fill: parent
}
onXChanged: {
mapMarker.x += x
}
onYChanged: {
mapMarker.y += y
}
}
onCoordinateChanged{
consol.log("coord",QtPositioning.coordinate(mapMarker.x ,mapMarker.y )}
}
}
}
我想拖动一个在组件内部声明的MapQuickItem并从地图获取实时坐标。我能够成功拖动组件,但是我拖动MapQuickItem快速鼠标光标离开...