I have two coordinates, and I need to restrict my Google Maps map to the frame bounded by those two coordinates. For example, I have
let bounds = GMSCoordinateBounds(
coordinate: CLLocationCoordinate2D(
latitude: 59.615440364671244,
longitude: -17.978949286043644
), coordinate: CLLocationCoordinate2D(
latitude: 33.963318167747758,
longitude: 21.442294009029865
)
)
Then, I write,
map.cameraTargetBounds = bounds
However, this does nothing to restrict the bounds of the map while it should. According to the documentation,
If not nil, [cameraTargetBounds] constrains the camera target so that gestures cannot cause it to leave the specified bounds.
This question did not help me, partially because I must allow zooming as well as panning––it just must be restricted to a certain area.
Why is this not working, and how can I fix it?