I'm using Google map and after adding lot of marker i want to move camera to newLatLngBounds to show all the marker visible to user. But i'm facing this Error.
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., null)
Future<void> getCenterMap() async {
double minlatitude = loadInformationMap[0]['latlng'].latitude,
maxlatitude = loadInformationMap[0]['latlng'].latitude,
minlongitude = loadInformationMap[0]['latlng'].longitude,
maxlongitude = loadInformationMap[0]['latlng'].longitude;
for (int i = 0; i < loadInformationMap.length; i++) {
if (minlatitude >= loadInformationMap[i]['latlng'].latitude) {
minlatitude = loadInformationMap[i]['latlng'].latitude;
}
if (minlongitude >= loadInformationMap[i]['latlng'].longitude) {
minlongitude = loadInformationMap[i]['latlng'].longitude;
}
if (maxlatitude <= loadInformationMap[i]['latlng'].latitude) {
maxlatitude = loadInformationMap[i]['latlng'].latitude;
}
if (maxlongitude <= loadInformationMap[i]['latlng'].longitude) {
maxlongitude = loadInformationMap[i]['latlng'].longitude;
}
}
googleMapController.animateCamera(CameraUpdate.newLatLngBounds(
LatLngBounds(
southwest: LatLng(minlatitude, minlongitude),
northeast: LatLng(maxlatitude, maxlongitude)),
100));
}