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 }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Called after the camera position has changed. During an animation, this listener may not be notified of intermediate camera positions. It is always called for the final position in the animation.
I currently can't give a ETA for this, mainly because I first need to first need to investigate if we actually are going to add this (check if there is no issue for performance and if we are willing to work around some of these issues).
Is there any way to achieve this on version 3.1.0?
Yes you could, first you need to listen to Map change events:
The callback invoked if camera position changed through gestures is not performant because we are have a flood of events when doing gestures (best example is panning). I'm thinking about implementing an idle timeout. Which means I will listen to MapChange events and will only invoke the callback if a certain timeout has passed and in that case the timeout will be reset.
Getting new value from global MapboxMap object seems to be a strange approach, can you clarify why it works in that way? All in all after moving camera listener parameter has old value and I get it 3 times...
When I change map position using gestures, it works fine and values are the same.
Another thing is getting notification after double tap (zoom-in gesture). I don't get new value of zoom - IMO callback isn't notified after it's finished. I came across MapView class:
// Called for double taps
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
if (mDestroyed || !mMapboxMap.getUiSettings().isZoomGesturesEnabled()) {
return false;
}
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
if (mQuickZoom) {
// insert here?
mQuickZoom = false;
break;
}
// Single finger double tap
if (mMapboxMap.getTrackingSettings().isLocationTrackingDisabled()) {
// Zoom in on gesture
zoom(true, e.getX(), e.getY());
} else {
// Zoom in on user location view
PointF centerPoint = mUserLocationView.getMarkerScreenPoint();
zoom(true, centerPoint.x, centerPoint.y);
}
break;
}
trackGestureEvent(MapboxEvent.GESTURE_DOUBLETAP, e.getX(), e.getY());
return true;
}
Of course it's only my guess, but isn't a problem with tracking this gesture or maybe callback should be notified in other way?
@tobrun I'd be grateful for any clarification, despite those two things (which blocks my in some situations) it works like a charm.
@mpuchala don't hesitate to open new tickets on the issue tracker,
sometimes these closed tickets are getting unnoticed.
I'm going to create follow up tickets for this.
Hello. Sorry for inconvenience but could you please help me with my porblem.
I'm writing android app with help of Android Studio. I'm using gradle and targetSdk 23. Also I'm using mapbox sdk 4.0.0-beta.2.
In my fragment I initialize mapbox maps something like this:
When I run my project and try to use scroll or fling gestures on the map (without stopping it), I see in logs that onCameraChange calls every 400 ms (average). But for me expected result that it called only one time: when camera will be stopped.
Maybe described situation is correct, but as I understood MapBox's OnCameraChangeListener is analog of GoogleMaps's OnCameraChangeListener and last works in the way that I described (onCameraChange calls only when camera will be in "idle" state). At least in mapbox documentation said same thing as in google maps documentation:
Called after the camera position has changed. During an animation, this listener may not be notified of intermediate camera positions. It is always called for the final position in the animation.
I came to this problem, because earlier I used google maps and used onCameraChange callback as indicator that map is in idle state (because I hide controls when work with map and want to show them, when camera is idle and I don't touch to map), and now I need to migrate to mapbox (because you have more and more better detalization of maps for some countries, like Russia), and I stunned with this problem.
So if it is not hard to you, could you please help me? Is calling onCameraChange during camera animation a bug or not? If not, does mapbox provide callbacks to know when camera is in the idle state?
Thank you.
BTW:
I'm testing on Nexus 5, v.6.0.1. And the previous example worked on Google maps.
@programmerr47, this issue report tracked feature work that was completed long ago, so none of the developers who can help you out are paying attention to this page. If you still have this question, please open a new issue so we can prioritize it correctly. Thank you for understanding.
@1ec5, thank you for your attention. I fully agree with your, so I've created an issue about month ago.
Here it is: #4746
I will glad if you will have some feedback about this problem. Thank you.
Activity
Trinea commentedon Feb 1, 2016
OnCameraChangeListener will be added in 4.0.0?
Trinea commentedon Feb 1, 2016
Is there any way to achieve functional equals to OnCameraChangeListener on version 3.1.0? thank you.
tobrun commentedon Feb 9, 2016
@Trinea:
I currently can't give a ETA for this, mainly because I first need to first need to investigate if we actually are going to add this (check if there is no issue for performance and if we are willing to work around some of these issues).
Yes you could, first you need to listen to Map change events:
Afterwards you will be able to
mInvalidCameraPositionis truetobrun commentedon Feb 9, 2016
I started investigating what needs to be done to actually have this in place:
CameraAPI has finished.tobrun commentedon Feb 9, 2016
The
callback invoked if camera API animation has finishedwill look like:tobrun commentedon Feb 9, 2016
The
callback invoked if camera position changed through gesturesis not performant because we are have a flood of events when doing gestures (best example is panning). I'm thinking about implementing an idle timeout. Which means I will listen to MapChange events and will only invoke the callback if a certain timeout has passed and in that case the timeout will be reset.tobrun commentedon Feb 9, 2016
I created these 2 clips to show the difference in performance by adding a CameraChangeListener:
This has given me enough evidence to optimise my remark above
tobrun commentedon Feb 9, 2016
To determine a good idle time, we first need to know how many invokes are occurring for each second:
That are 112 callbacks occurring in one second! which is way too much
tobrun commentedon Feb 9, 2016
View the the result after rate limiting the updates to 250 ms here
The logs for 250ms:
You can see we are having max 4 updates / sec.
tobrun commentedon Feb 9, 2016
View the result after rate limiting the updates to 100ms here.
The logs for 100ms:
You can see we are having max 10 updates / sec
tobrun commentedon Feb 9, 2016
There is visual not that much difference between 100/250ms, except when having both side-by-side:
There is a light increase for 100 ms.
tobrun commentedon Feb 9, 2016
I'm thinking about using 400ms, this will result in 2-3 updates / sec.
We can revisit this later and tweak the configuration if needed.
1 remaining item
[android] #3745 - MapboxMap.OnCameraChangeListener 📷
Trinea commentedon Feb 17, 2016
@tobrun Thank you very much, I will try later.
mpuchala commentedon Mar 14, 2016
Hi guys,
I'm a bit confused about this listener. I'm setting new position (of course just once):
mMapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));That works fine but the problem is with returned value, this is my basic code:
and here is log:
Getting new value from global MapboxMap object seems to be a strange approach, can you clarify why it works in that way? All in all after moving camera listener parameter has old value and I get it 3 times...
When I change map position using gestures, it works fine and values are the same.
Thank's in advance for any suggestions.
mpuchala commentedon Mar 15, 2016
Another thing is getting notification after double tap (zoom-in gesture). I don't get new value of zoom - IMO callback isn't notified after it's finished. I came across MapView class:
Of course it's only my guess, but isn't a problem with tracking this gesture or maybe callback should be notified in other way?
@tobrun I'd be grateful for any clarification, despite those two things (which blocks my in some situations) it works like a charm.
tobrun commentedon Mar 15, 2016
@mpuchala don't hesitate to open new tickets on the issue tracker,
sometimes these closed tickets are getting unnoticed.
I'm going to create follow up tickets for this.
mpuchala commentedon Mar 15, 2016
Sure, thanks!
tobrun commentedon Mar 15, 2016
I created these 2 follow up tickets:
programmerr47 commentedon Apr 18, 2016
Hello. Sorry for inconvenience but could you please help me with my porblem.
I'm writing android app with help of Android Studio. I'm using gradle and targetSdk 23. Also I'm using mapbox sdk 4.0.0-beta.2.
In my fragment I initialize mapbox maps something like this:
When I run my project and try to use scroll or fling gestures on the map (without stopping it), I see in logs that onCameraChange calls every 400 ms (average). But for me expected result that it called only one time: when camera will be stopped.
Maybe described situation is correct, but as I understood MapBox's OnCameraChangeListener is analog of GoogleMaps's OnCameraChangeListener and last works in the way that I described (onCameraChange calls only when camera will be in "idle" state). At least in mapbox documentation said same thing as in google maps documentation:
I came to this problem, because earlier I used google maps and used onCameraChange callback as indicator that map is in idle state (because I hide controls when work with map and want to show them, when camera is idle and I don't touch to map), and now I need to migrate to mapbox (because you have more and more better detalization of maps for some countries, like Russia), and I stunned with this problem.
So if it is not hard to you, could you please help me? Is calling onCameraChange during camera animation a bug or not? If not, does mapbox provide callbacks to know when camera is in the idle state?
Thank you.
BTW:
I'm testing on Nexus 5, v.6.0.1. And the previous example worked on Google maps.
1ec5 commentedon May 24, 2016
@programmerr47, this issue report tracked feature work that was completed long ago, so none of the developers who can help you out are paying attention to this page. If you still have this question, please open a new issue so we can prioritize it correctly. Thank you for understanding.
programmerr47 commentedon May 24, 2016
@1ec5, thank you for your attention. I fully agree with your, so I've created an issue about month ago.
Here it is: #4746
I will glad if you will have some feedback about this problem. Thank you.