I am trying focus the map on the marker at a certain zooming ratio. I've looked at a couple posts in stackoverflow and I couldn't see any reason why I am getting the following error:
java.lang.IllegalStateException: Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0
Most likely, layout has not yet occured for the map view. Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int)
which allows you to specify the map's dimensions.
The code that I am using is:
private void setUpMap(String address) throws IOException {
Geocoder gc = new Geocoder(this);
List<Address> list = gc.getFromLocationName(address, 1);
Address add = list.get(0);
double Longitude = add.getLongitude();
double Latitude= add.getLatitude();
Marker m = mMap.addMarker(new MarkerOptions().position(new LatLng(Latitude, Longitude)).title(address));
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(m.getPosition());
LatLngBounds bounds = builder.build();
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10));
}
I debugged the code, and it is throwing the previous exception on the line
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10));
Any suggestion here? thanks...