Reputation: 11039
How to disable Google Maps SDK double tap zooming (but not pinch zooming) in iOS SDK?
Thank You
Upvotes: 2
Views: 3468
Reputation: 1
put this in controller
/// this gesture will disable zoom gesture temporarily
var tmpDisableZoom: UITapGestureRecognizer!
/// how long you want to lock
let lockDoubleTapTimeDelay = 0.3
/// finally unlock time
var unlockDoubleTapTime = Date().timeIntervalSince1970
override func viewDidLoad() {
mapView.settings.consumesGesturesInView = false
tmpDisableZoom = UITapGestureRecognizer(target: self, action: #selector(removeZoomGesturesTemporarily))
tmpDisableZoom.numberOfTapsRequired = 1
}
@objc func removeZoomGesturesTemporarily(sender:UIGestureRecognizer){
mapView.settings.zoomGestures = false
unlockDoubleTapTime = Date().timeIntervalSince1970
DispatchQueue.main.asyncAfter(deadline: .now() + lockDoubleTapTimeDelay) { [weak self] in
guard self != nil else {return}
let timeNow = Date().timeIntervalSince1970
if timeNow - self!.unlockDoubleTapTime > self!.lockDoubleTapTimeDelay{
self!.mapView.settings.zoomGestures = true
}
}
}
Upvotes: 0
Reputation: 7152
For Swift 2.1
You can do this on your GMSMapView
object,
mapView.settings.zoomGestures = false
Same goes for disabling tilt gesture, rotate gesture, scroll gestures,
mapView.settings.tiltGestures = false
mapView.settings.rotateGestures = false
mapView.settings.scrollGestures = false
Read more here: https://developers.google.com/maps/documentation/ios-sdk/controls#map_gestures
Unfortunately there is no way to disable double tap zoom while still keeping pinch zoom gestures. (I could be wrong, but I have went through their docs and haven't found a way to do so)
Upvotes: 3
Reputation: 50099
install your own tapgesturerecognizer and make it receive double taps. that way it won't be given to the google map.
Upvotes: 0