Search code examples
mapboxmapbox-android

Consume click when dragging an annotation


I am using addOnMapLongClickListener to create annotations on long clicks. Something like:

mapboxMap.addOnMapLongClickListener(point -> {
  // create an annotation here
  return true;
});

Those annotations are created "draggable". Something like:

CircleOptions circleOptions = new CircleOptions()
    .withLatLng(latLng)
    .withCircleColor(ColorUtils.colorToRgbaString(Color.YELLOW))
    .withCircleRadius(12f)
    .withDraggable(true);

circleManager.create(circleOptions);

And I can drag the annotation without a problem. The thing is that it also triggers the long click listener, and therefore dragging an annotation results in the creation of a new one at the previous position.

How can I make it such that a drag does not trigger the long click listener on the map?


Solution

  • Just realized it is actually a known issue.