use of com.mapbox.android.gestures.MoveDistancesObject in project mapbox-plugins-android by mapbox.
the class DraggableAnnotationController method onMove.
boolean onMove(MoveGestureDetector detector) {
if (draggedAnnotation != null && (detector.getPointersCount() > 1 || !draggedAnnotation.isDraggable())) {
// Stopping the drag when we don't work with a simple, on-pointer move anymore
stopDragging(draggedAnnotation, draggedAnnotationManager);
return true;
}
// Updating symbol's position
if (draggedAnnotation != null) {
MoveDistancesObject moveObject = detector.getMoveObject(0);
float x = moveObject.getCurrentX() - touchAreaShiftX;
float y = moveObject.getCurrentY() - touchAreaShiftY;
PointF pointF = new PointF(x, y);
if (pointF.x < 0 || pointF.y < 0 || pointF.x > touchAreaMaxX || pointF.y > touchAreaMaxY) {
stopDragging(draggedAnnotation, draggedAnnotationManager);
return true;
}
Geometry shiftedGeometry = draggedAnnotation.getOffsetGeometry(mapboxMap.getProjection(), moveObject, touchAreaShiftX, touchAreaShiftY);
if (shiftedGeometry != null) {
draggedAnnotation.setGeometry(shiftedGeometry);
draggedAnnotationManager.internalUpdateSource();
for (OnAnnotationDragListener d : (List<OnAnnotationDragListener>) draggedAnnotationManager.getDragListeners()) {
d.onAnnotationDrag(draggedAnnotation);
}
return true;
}
}
return false;
}
Aggregations