From cecdc5a0ae12df8b09d30391c4bd429fd4f41b21 Mon Sep 17 00:00:00 2001 From: leonid Date: Fri, 16 Jul 2021 11:20:38 -0700 Subject: [PATCH] fix drag issues --- .../annotation/DraggableAnnotationController.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/DraggableAnnotationController.java b/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/DraggableAnnotationController.java index b9be243d5..2222bd865 100644 --- a/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/DraggableAnnotationController.java +++ b/plugin-annotation/src/main/java/com/mapbox/mapboxsdk/plugins/annotation/DraggableAnnotationController.java @@ -81,7 +81,12 @@ public boolean onTouch(View v, MotionEvent event) { Annotation oldAnnotation = draggedAnnotation; androidGesturesManager.onTouchEvent(event); // if drag is started or drag is finished, don't pass motion events further - return draggedAnnotation != null || oldAnnotation != null; + + // Note(leo): added check for MotionEvent.ACTION_MOVE, + // without this all the draggable markers will receive onLongClick event when you single tapped :/ + // and that is coming from an android View (perform long click) + return draggedAnnotation != null || oldAnnotation != null + && event.getAction() == MotionEvent.ACTION_MOVE; } }); } @@ -134,6 +139,12 @@ boolean onMove(MoveGestureDetector detector) { return true; } + if (moveObject.getDistanceXSinceStart() == 0 && moveObject.getDistanceYSinceStart() == 0 + && moveObject.getDistanceXSinceLast() == 0 && moveObject.getDistanceYSinceLast() == 0) { + // fix the bug where you didn't actually touch drag with a finger but get the marker moved + return true; + } + Geometry shiftedGeometry = draggedAnnotation.getOffsetGeometry( mapboxMap.getProjection(), moveObject, touchAreaShiftX, touchAreaShiftY );