wrapLatLngBounds method
Returns a LatLngBounds
with the same size as the given one,
ensuring that its center is within the CRS's bounds.
Only accepts actual LatLngBounds
instances, not list [].
Implementation
@override
LatLngBounds wrapLatLngBounds(LatLngBounds bounds) {
LatLng center = bounds.center;
LatLng newCenter = wrapLatLng(center);
double latShift = center.lat - newCenter.lat;
double lngShift = center.lng - newCenter.lng;
if (latShift == 0 && lngShift == 0) {
return bounds;
}
LatLng sw = bounds.southWest!;
LatLng ne = bounds.northEast!;
LatLng newSw = LatLng(sw.lat - latShift, sw.lng - lngShift);
LatLng newNe = LatLng(ne.lat - latShift, ne.lng - lngShift);
return LatLngBounds(newSw, newNe);
}