把地图调整到合适的区域,一定要注意LatLngBounds 传入的是 西南角坐标[southwest]和东北角坐标[northeast]
double firstLatitude = location1.latitude;
double lastLatitude = location2.latitude!;
double firstLongitude = location1.longitude!;
double lastLongitude = location2.longitude!;
LatLng southwest = LatLng(min(firstLatitude, lastLatitude),min(firstLongitude, lastLongitude));
LatLng northeast = LatLng(max(firstLatitude, lastLatitude),max(firstLongitude, lastLongitude));
LatLngBounds bounds = LatLngBounds(southwest: southwest, northeast: northeast);
CameraUpdate update = CameraUpdate.newLatLngBounds(bounds, 50);
_mapController?.moveCamera(update);
网友评论