mapbox / mapbox-plugins-android

Mapbox Android Plugins are a collection of libraries that extend our other SDKs, helping you design powerful mapping features while the plugins handle most of the heavy lifting.
https://www.mapbox.com/android-docs/plugins/overview/
BSD 2-Clause "Simplified" License
241 stars 119 forks source link

Annotations not draggable if not the latest instantiated XxxManager #1122

Closed Ph0tonic closed 4 years ago

Ph0tonic commented 4 years ago

Hello,

I encountered a strange behaviour. When I create a marker via a CircleManager on which I add a draggableListener then if I instantiate another Manager(Symbol, Circle, ...) afterwards then my listener is not triggered any more. This happens even if I set the next Manager to be below my CircleManager layer using the belowLayerId property.

Do you have any clue on what could cause this issue ? Thanks in advance

Ph0tonic commented 4 years ago

I had a look at the code and I found the following inside DraggableAnnotationController.java :

mapView.setOnTouchListener(new View.OnTouchListener() {
      @Override
      public boolean onTouch(View v, MotionEvent event) {
        androidGesturesManager.onTouchEvent(event);
        // if drag is started, don't pass motion events further
        return draggedAnnotation != null;
      }
    });

From what I know, I think that we replace the touchListener of mapView whenever we create a new AnnotationManager which lead to this bug.

Ph0tonic commented 4 years ago

Duplicated of #863, I'll close this issue.