如何在iOS SDK中禁用Google Maps SDK双击缩放(但不能缩放缩放)?
谢谢
答案 0 :(得分:3)
对于Swift 2.1
您可以在GMSMapView
对象
mapView.settings.zoomGestures = false
同样适用于禁用倾斜手势,旋转手势,滚动手势,
mapView.settings.tiltGestures = false
mapView.settings.rotateGestures = false
mapView.settings.scrollGestures = false
在此处阅读更多内容:https://developers.google.com/maps/documentation/ios-sdk/controls#map_gestures
不幸的是,在保持捏缩放手势的同时无法禁用双击缩放。 (我可能是错的,但我已经完成了他们的文档并且没有找到办法这样做)
答案 1 :(得分:1)
试试这个:
[googleMapView.settings setAllGesturesEnabled:NO];
答案 2 :(得分:0)
安装自己的tapgesturerecognizer并使其获得双击。这样就不会给谷歌地图了。
答案 3 :(得分:0)
将其放入控制器
/// 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
}
}
}