Implement cancel draggable during onAnnotationDrag by Ph0tonic · Pull Request #1129 · mapbox/mapbox-plugins-android · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ public void onAnnotationDragStarted(Symbol annotation) {
}

@Override
public void onAnnotationDrag(Symbol annotation) {
public boolean onAnnotationDrag(Symbol annotation) {
draggableInfoTv.setText(String.format(
Locale.US,
"ID: %s\nLatLng:%f, %f",
annotation.getId(),
annotation.getLatLng().getLatitude(), annotation.getLatLng().getLongitude()));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,18 @@ boolean onMove(MoveGestureDetector detector) {
);

if (shiftedGeometry != null) {
Geometry oldGeometry = draggedAnnotation.geometry;
draggedAnnotation.setGeometry(
shiftedGeometry
);
annotationManager.internalUpdateSource();
if (!annotationManager.getDragListeners().isEmpty()) {
for (D d : annotationManager.getDragListeners()) {
d.onAnnotationDrag(draggedAnnotation);
if (!d.onAnnotationDrag(draggedAnnotation)) {
draggedAnnotation.setGeometry(oldGeometry);
stopDragging(draggedAnnotation);
return true;
}
}
}
return true;
Expand Down