0

Similar questions have been asked before but I want the restriction to work "smooth", e.g. when you have a horizontal and a vertical panning vector (e.g. you pan the map side and upwards), the map should not just stop at the first encounter of the restriction bounding box and stop all movements.

I imagine that you should be able to generously pan "inside" that bounding box and the inertia of all map panning should be kept. The component (lat/long) that hits a "barrier" should be bouncing back and the other component should scroll further until the scrolling momentum is finished.

How would I go about implementing such a function?

Beat Rupp
  • 319
  • 3
  • 12
  • Try restricting the latitude and longitude of the map – Kanishk Gupta Feb 02 '21 at 17:16
  • How exactly? Could you give an example? – Beat Rupp Feb 08 '21 at 12:48
  • Change the coordinates here... let northEast = CLLocationCoordinate2D(latitude: -33.8683, longitude: 151.2086) let southWest = CLLocationCoordinate2D(latitude: -33.994065, longitude: 151.251859) let bounds = GMSCoordinateBounds(coordinate: northEast, coordinate: southWest) let update = GMSCameraUpdate.fit(bounds, withPadding: 50.0) mapView.moveCamera(update) – Kanishk Gupta Feb 08 '21 at 16:06

0 Answers0