-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[android] Problem with CameraIdleListener #12260
Comments
@swsong12 Thanks for reaching out! Firing multiple |
Is there anyway to figure out the target zoom level right after pinch? In other words, the user will land on a specific zoom level after user releases his or her fingers. Can we know this final/targeted zoom level user lands on as soon as user releases his/her fingers? |
@LukasPaczos Do you have any information how long it will take to improve / fix camera idle listener? I'm having same issues as in #10923 . I'm using 6.2.1 version of the library and this is a problem for me. |
@pawelwichniewicz we're tracking the issue but can't provide any concrete timeline for the required changes yet. |
@pawelwichniewicz @swsong12 Edit: I've changed this code since writing it, since the mIsCameraIdle boolean in
|
@mf16 I've been using something similar, but I've tested on a few devices and found that a delay of only 50 ms is sufficient. The difference may be that I've gone back to 5.x due to an unrelated performance issue with 6.x. public abstract class OnCameraReallyIdleListener implements OnCameraMoveListener, OnCameraIdleListener {
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final long mDelay;
private Runnable mCallback;
public OnCameraReallyIdleListener(final long delay) {
mDelay = delay;
}
@Override
public final void onCameraMove() {
removeCallbacks();
}
@Override
public final void onCameraIdle() {
removeCallbacks();
mCallback = () -> {
onCameraReallyIdle();
mCallback = null;
};
mHandler.postDelayed(mCallback, mDelay);
}
public final void removeCallbacks() {
if(mCallback != null) {
mHandler.removeCallbacks(mCallback);
mCallback = null;
}
}
abstract public void onCameraReallyIdle();
} |
To give a little bit more context here, the issue originates from the separation of direct movement and velocity animated movement. The idea of separation and general solution are being tracked in mapbox/mapbox-gestures-android#13. |
Thanks for the patience on this one. The solution has been shipped with the |
i'm still having the issue with 6.6.0_alpha.2 getting moveCanceled , onMove and Idle callBacks at the same time when panning :( |
I'm still seeing this in 6.7.0 |
I adapted @kjkrum 's idea using Kotlin Coroutines: val scope = LifecycleScope()
init {
lifecycle.addObserver(scope)
}
private var cameraIdleJob: Job? = null
override fun onCameraIdle() {
cameraIdleJob?.cancel()
cameraIdleJob = scope.launch {
delay(50)
// DO WORK HERE
}
}
override fun onCameraMove() {
cameraIdleJob?.cancel()
} Like him, I found that a 50ms delay seems to work. |
@percula if you are referring to
it should've been resolved. Are you still hitting the issue? |
@LukasPaczos , yeah I was still getting the issue in Mapbox 6.8.1. It was being called maybe a dozen times when the map first loaded (maybe also on pinch/zoom but I haven't tested that). On start, I reposition the map to the user's current location, but that should only result in 2 calls, not a dozen. |
Sounds like a different issue then, would you mind opening a new ticket with reproduction steps and logs? Thank you! |
Thanks! I'll do some more debugging just to make sure it's not my fault. If my implementation looks good, I'll open a new ticket. |
When I add geoJsonlayer on map and also bind onCameraIdle event that's why I don't get onMarkerClick event lister.please help.Thanks in Advance. |
Platform: android
Mapbox SDK version: 6.2.0
Steps to trigger behavior
Issue
When I try to pinch to zoom (in/out) OnCameraIdleListener is called multiple times. We tried couple of work arounds such as using 200ms timeout after when camera idle is detected. Yet, this method is not optimal for user experience because timeout seems to vary among different devices. In other words, this work around works like a charm on some devices, but not on the other devices.
So I am curious if there is anyway to figure out the zoom level, which the user will land after user releases his or her fingers.
Or
Is there any way to figure out the optimal timeout value? Currently, we are using guessed value of 200ms (really rough estimate).
Thank you!
The text was updated successfully, but these errors were encountered: