You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mapView.setOnTouchListener#onTouch is not invoked with Annotations #884
changed the title [-]mapView.setOnToucListener#onTouch is not invoked with Annotations[/-][+]mapView.setOnTouchListener#onTouch is not invoked with Annotations[/+]on Mar 18, 2019
LineManager is an implementation of AnnotationManager which uses a DraggableAnnotationController which also sets a touchListener on the mapView.
Unfortunately, you can only set one touchListener on the View (it's a setOnTouchListener, not an addOnTouchListener)
The current conclusion is that you can't do both at the same time. One other workaround would be to add a callback to be called before androidGesturesManager.onTouchEvent(event); is triggered. Another one if you are using the androidGesturesManager would be to have is injected in like it's done in the second constructor currently.
Thanks, in my use case I have a Mapview inside a RecyclerView. Based on the touch coordinate point, I set the flag for parent.requestDisallowInterceptTouchEvent().
Thanks, in my use case I have a Mapview inside a RecyclerView. Based on the touch coordinate point, I set the flag for parent.requestDisallowInterceptTouchEvent().
You can use your custom Mapview. This mapview extends mapview and override onTouchEvent()
Like below in my case:
public static class CustomMapView extends MapView {
public CustomMapView(@NonNull Context context) {
super(context);
}
public CustomMapView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public CustomMapView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public CustomMapView(@NonNull Context context, @Nullable MapboxMapOptions options) {
super(context, options);
}
List<MapTouchListener> mapDownUpListeners = new ArrayList<>();
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
if (event.getAction() == KeyEvent.ACTION_DOWN) {
for (MapTouchListener listener : mapDownUpListeners) {
listener.onTouchDown();
}
return true;
} else if (event.getAction() == KeyEvent.ACTION_UP) {
for (MapTouchListener listener : mapDownUpListeners) {
listener.onTouchUp();
}
return true;
}
return true;
}
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Getting the same problem. I have my MapView inside a RecyclerView, trying to catch onToucheEvent callback but do not get anything so far. Huge problem as my MapView is not scrollable inside my RecyclerView. Does anyone has a fix for this ?
Activity
[-]mapView.setOnToucListener#onTouch is not invoked with Annotations[/-][+]mapView.setOnTouchListener#onTouch is not invoked with Annotations[/+]ulusoyca commentedon Mar 19, 2019
As a workaround until there is a fix, this ugly trick solves the issue:
sebastienrouif commentedon Mar 21, 2019
LineManager is an implementation of AnnotationManager which uses a DraggableAnnotationController which also sets a touchListener on the mapView.
Unfortunately, you can only set one touchListener on the
View(it's asetOnTouchListener, not anaddOnTouchListener)The current conclusion is that you can't do both at the same time. One other workaround would be to add a callback to be called before androidGesturesManager.onTouchEvent(event); is triggered. Another one if you are using the androidGesturesManager would be to have is injected in like it's done in the second constructor currently.
Could you explain your use case?
ulusoyca commentedon Mar 21, 2019
Thanks, in my use case I have a
Mapviewinside aRecyclerView. Based on the touch coordinate point, I set the flag forparent.requestDisallowInterceptTouchEvent().dongzhixuanyuan commentedon Apr 8, 2019
You can use your custom Mapview. This mapview extends mapview and override onTouchEvent()
Like below in my case:
public static class CustomMapView extends MapView {
stale commentedon Oct 5, 2019
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Oct 5, 2019
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.
houdayec commentedon Jan 9, 2020
Getting the same problem. I have my MapView inside a RecyclerView, trying to catch onToucheEvent callback but do not get anything so far. Huge problem as my MapView is not scrollable inside my RecyclerView. Does anyone has a fix for this ?
Ph0tonic commentedon Dec 29, 2020
I just pushed a PR to fix this issue, see #1157. Hope this will help.