Disable Google Map move on double tap in iOS

I am using the Google Maps SDK for my iOS app.

You can zoom in on the map using either of two gestures.

  • Double tap
  • Double tap → Hold → Drag down

First, the map zooms in, but the map shifts near the position where I double-tap. Although in the second method, the map is scaled to be in the current center of the map.

I want the second type of behavior (the card stays on the current center, not on the transfer) for the first gesture. How should I do it?

EDIT: Basically the behavior should be the same as in the Official Google Map Double Tap.

+3


source to share


2 answers


You can turn off the default gesture on the map by setting the properties of the GMSUISettings class, which is available as a property of the GMSMapView. The following gestures can be enabled and disabled programmatically. Note: Disabling gestures does not restrict software access to camera settings.

scrollGestures - Controls whether scroll gestures are enabled or disabled. If enabled, users can scroll the camera to pan.

zoomGestures - controls to enable or disable zoom gestures. If allowed, users can double-tap, with two fingers, or pinch to zoom in on the camera. Note that double-clicking can pan the camera to the specified point.

tiltGestures - Controls whether tilt gestures are enabled or disabled. If allowed, users can use two fingers vertically down or up to tilt the camera.



rotateGestures - Controls whether rotate gestures are enabled or disabled. If allowed, users can use two-finger rotation to rotate the camera.

In the example below, pan and zoom gestures are disabled.

(void)loadView {
  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285
                                                          longitude:103.848
                                                               zoom:12];
  mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  mapView_.settings.scrollGestures = NO;
  mapView_.settings.zoomGestures = NO;
  self.view = mapView_;
}

      

+2


source


This is a config item in the GMSUISettings class, so you can access it from the property of the GMSMapView

object as shown below,

Obj-C:

mapView.settings.allowScrollGesturesDuringRotateOrZoom = NO;

      



Swift 2.1:

mapView.settings.allowScrollGesturesDuringRotateOrZoom = false

      

I needed to find the source code to find this config item that is not mentioned anywhere in the docs.

+2


source







All Articles