My app shows a map and i want that users can\'t swipe over a certain region. So i\'m trying to add bounds but it makes the app to crash. Here is the working code:
Caused by: java.lang.IllegalStateException: Map size should not be 0. Most likely, layout has not yet occured for the map view.
The reason Behind this error is because the Map layout has not been completed, You should implement OnMapReadyCallback in your calls, which will ensure that your code will only run after your layout is completed or Implement the below callback
map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition arg0) {
map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 30));
}
});
Duplicate Links
moveCamera with CameraUpdateFactory.newLatLngBounds crashes
IllegalStateException map size should not be 0
I don't if there is a way to merge this link. I Hope i helped