Commit c6091ed4 authored by Don Gagne's avatar Don Gagne

Fix mobile polygon draw

parent 07b8674a
...@@ -349,8 +349,17 @@ Map { ...@@ -349,8 +349,17 @@ Map {
// Add first coordinate // Add first coordinate
polygonPath.push(clickCoordinate) polygonPath.push(clickCoordinate)
} else { } else {
// Update finalized coordinate // Add subsequent coordinate
polygonPath[polygonDrawerPolygon.path.length - 1] = clickCoordinate if (ScreenTools.isMobile) {
// Since mobile has no mouse, the onPositionChangedHandler will not fire. We have to add the coordinate
// here instead.
polygonDrawer.justClicked = false
polygonPath.push(clickCoordinate)
} else {
// The onPositionChanged handler for mouse movement will have already added the coordinate to the array.
// Just update it to the final position
polygonPath[polygonDrawerPolygon.path.length - 1] = clickCoordinate
}
} }
polygonDrawerPolygonSet.path = polygonPath polygonDrawerPolygonSet.path = polygonPath
polygonDrawerPolygon.path = polygonPath polygonDrawerPolygon.path = polygonPath
...@@ -360,10 +369,15 @@ Map { ...@@ -360,10 +369,15 @@ Map {
} }
onPositionChanged: { onPositionChanged: {
if (ScreenTools.isMobile) {
// We don't track mouse drag on mobile
return
}
if (polygonDrawerPolygon.path.length) { if (polygonDrawerPolygon.path.length) {
var dragCoordinate = _map.toCoordinate(Qt.point(mouse.x, mouse.y)) var dragCoordinate = _map.toCoordinate(Qt.point(mouse.x, mouse.y))
var polygonPath = polygonDrawerPolygon.path var polygonPath = polygonDrawerPolygon.path
if (polygonDrawer.justClicked){ if (polygonDrawer.justClicked){
// Add new drag coordinate
polygonPath.push(dragCoordinate) polygonPath.push(dragCoordinate)
polygonDrawer.justClicked = false polygonDrawer.justClicked = false
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment