title: Prevent scrolling outside map area on google map
body: <p>Am actually dealing with the Google Maps Framework for iOS, and I want to block scrolling out side a giving area.</p>
  
  <p>What I tried to do at first, implement the delegate method : <code>- (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position</code> and compare the map position with the right/left corners.But what I did has many issues when scrolling or zooming. </p>
  
  <p>Below an exemple of my implementation : </p>
  
  <pre><code> - (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position {  
  
      if (position.target.latitude &gt; topLat) { 
          GMSCameraPosition *goBackCamera = [GMSCameraPosition cameraWithLatitude:topLat
                                                                        longitude:position.target.longitude
                                                                              zoom:position.zoom
                                                                              bearing:220
                                                                              viewingAngle:0];
  
          [self.mapView animateToCameraPosition:goBackCamera];
      }
  
      if (position.target.latitude &lt; bottomLat) {
          GMSCameraPosition *goBackCamera = [GMSCameraPosition cameraWithLatitude:bottomLat
                                                                        longitude:position.target.longitude
                                                                             zoom:position.zoom
                                                                          bearing:220
                                                                     viewingAngle:0];
          [self.mapView animateToCameraPosition:goBackCamera];
      }
  
      if (position.target.longitude &gt; rightLong) {
          GMSCameraPosition *goBackCamera = [GMSCameraPosition cameraWithLatitude:position.target.latitude
                                                                        longitude:rightLong
                                                                             zoom:position.zoom
                                                                          bearing:220
                                                                     viewingAngle:0];
          [self.mapView animateToCameraPosition:goBackCamera];
      }
  
      if (position.target.longitude &lt; leftLong) {
          GMSCameraPosition *goBackCamera = [GMSCameraPosition cameraWithLatitude:position.target.latitude
                                                                        longitude:leftLong
                                                                             zoom:position.zoom
                                                                          bearing:220
                                                                     viewingAngle:0];
          [self.mapView animateToCameraPosition:goBackCamera];
      }
  }
  </code></pre>
  
  <p>Do you no a way more efficient to deal with this?</p>
  
  <p>PS: TopLat, RightLong ... mean top Latitude and Right longitude etc </p>
  
  <p>Regards</p>