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.
Map goes blank when animating dezoom #8300
Copy link
Copy link
Closed
Labels
CoreThe cross-platform C++ core, aka mbgl
Description
Platform: Android
Mapbox SDK version: 4.2.2
Steps to trigger behavior
- Create a minimal app (largely inspired by the sample app):
public class MainActivity extends Activity {
MapView mapView;
MapboxMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapboxAccountManager.start(getApplicationContext(), "mapbox token goes here");
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap map) {
MainActivity.this.map = map;
double distance = 0.001;
LatLngBounds bounds = new LatLngBounds.Builder()
.include(new LatLng(48.866800199999986 - distance, 2.3536729199999993 - distance))
.include(new LatLng(48.866800199999986 + distance, 2.3536729199999993 + distance))
.build();
map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10));
map.setOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
// works:
// MainActivity.this.map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.866800199999986, 2.3536729199999993), 0));
// doesn't work:
// (coordinates could be something else)
MainActivity.this.map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.866800199999986, 2.3536729199999993), 0), 100);
}
});
}
});
}
// Add the mapView lifecycle to the activity's lifecycle methods
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
}- Tap the map
Expected behavior
Tapping the map should make us dezoom to the earth view
Actual behavior
Tapping the map causes the map to disappear
Notes
Upon investigation:
- debugging shows that camera position target LatLng has NaN longitude
- using moveCamera instead of animateCamera works
Based on these observations, my guess would be that something goes wrong near https://github.com/mapbox/mapbox-gl-native/blob/master/src/mbgl/map/transform.cpp#L169
Thank's in advance for your help!
Reacted by Antoine Martin, Steeve Morin, Marc Rollin, Pierre Leveau, Benoit Goby, Yi MIN, Benjamin Rodde, Laurent Cerveau, Jean Kruger, Clement Rey and 6 more
Activity
plailleur commentedon Mar 7, 2017
+1
jeankruger commentedon Mar 7, 2017
+1
tobrun commentedon Mar 7, 2017
Thank you for reaching out, the many up votes and providing the code to reproduce.
tobrun commentedon Mar 7, 2017
I have been log-debugging the C++ code, it seems that the calculated start point and end point are the same when we are attempting
startTransitioninTransform::flyTo. This is because the target LatLng is rounded in the process. Since there isn't a change of the camera position target LatLng, I'm going to add an if check to validate for same position and execute aneaseToinstead.Update: above observation is false, I was mislead by the logger as it rounds values.
tobrun commentedon Mar 7, 2017
Linking #8097 as this is exactly the same issue though I'm getting values for
u1 : 1.962334while that PR would only fix it foru1 < 0.5.tobrun commentedon Mar 7, 2017
Was able to pinpoint the source of the NaN LatLngs, it seems that the Zoom-out factor during ascent = infinite.
mrlem commentedon Mar 7, 2017
Thanks for the feedback! (and this great project, by the way)
Indeed, the distance between start and end position seems to play a role, I used a test code with the same value, but moving a target with some significant distance seems to be a problem too.
e.g. map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.766800199999986, 2.3536729199999993), 0), 100);
... triggers the problem
map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(47.766800199999986, 2.3536729199999993), 0), 100);
... doesn't
So there's definitely a threshold at play.
tobrun commentedon Mar 13, 2017
@1ec5
In case you want to try reproducing this one iOS:
The initial camera values are:
The flyTo camera values are:
fix #8300 flyTo for close points
fix #8300 flyTo for close points
Merge branch 'release-ios-v3.6.0-android-v5.1.0' into merge_mapbox_v5_1
Merge release-ios-v3.6.0-android-v5.1.0 (#9416)