Reputation: 141
I am using the Google Maps SDK for my iOS App.
You can zoom in on the map using either of two gestures.
In the first way, the map zooms in, but the map shifts near to the position where I double tap. While in the second method, the map zooms in staying at the current map centre.
I want to achieve the second type of behaviour(map staying on current centre rather than shifting) on the first gesture too. How do I go about it?
EDIT: Basically the behaviour should be same as the Official Google Map Double Tap.
Upvotes: 5
Views: 4724
Reputation: 7152
This is a config item in GMSUISettings class, so you can access it on your GMSMapView
object's 'settings' property like below,
Obj-C:
mapView.settings.allowScrollGesturesDuringRotateOrZoom = NO;
Swift 2.1:
mapView.settings.allowScrollGesturesDuringRotateOrZoom = false
I had to dig into their source code to find this config item, its not mentioned anywhere in the docs.
Upvotes: 5
Reputation: 8459
You can disable the default gestures on the map by setting 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 the gesture will not limit programmatic access to the camera settings.
scrollGestures — controls whether scroll gestures are enabled or disabled. If enabled, users may swipe to pan the camera.
zoomGestures — controls whether zoom gestures are enabled or disabled. If enabled, users may double tap, two-finger tap, or pinch to zoom the camera. Note that double tapping may pan the camera to the specified point.
tiltGestures — controls whether tilt gestures are enabled or disabled. If enabled, users may use a two-finger vertical down or up swipe to tilt the camera.
rotateGestures — controls whether rotate gestures are enabled or disabled. If enabled, users may use a two-finger rotate gesture to rotate the camera.
In the below example, both pan and zoom gestures have been 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_;
}
Upvotes: 3