-
Notifications
You must be signed in to change notification settings - Fork 1.3k
LatLngBounds not applied in OnMapReady #6769
Comments
Noticing that viewportheight is 0, which means the MapView hasn't been measured yet. |
Workaround for now is posting the update on the main thread: new Handler().post(new Runnable() {
@Override
public void run() {
// Move camera to the bounds with added padding
int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin);
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
}
}); |
Ideally this is fixed with a more robust camera system in #6532 (+ improvement over current implementation in #4796). One solution for now would be post every cc @mapbox/android |
Capturing from @ivovandongen to do a small test with the reverted OnMapReadyCallback (hooking into DID_FINISH_LOADING_MAP instead). This correctly animates the map: |
From the (duplicate) #6855 While I believe the final solution will work, the workaround may not work for everybody. |
@gerhardol I would suggest using a |
Thanks
|
In #6919 I'm introducing the runnable around the camera methods for another issue (running an animation in onFinish). To completely resolve this issue we need to optimise the OnMapReadyCallback to take in account if style is loaded but also if the view is measured yet. |
#6999 is the issue tracking the solution for this. Closing as a duplicate |
Current:
Desired result:
Map centers around 🇺🇸
The text was updated successfully, but these errors were encountered: