如何在 iOS SDK 中禁用 Google Maps SDK 双击缩放(但不是捏缩放)?
谢谢你
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)
尝试这个 :
[googleMapView.settings setAllGesturesEnabled:NO];
安装您自己的 Tapgesturerecognizer 并使其接收双击。这样它就不会被提供给谷歌地图。
把它放在控制器中
/// 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
}
}
}