2

如何在 iOS SDK 中禁用 Google Maps SDK 双击缩放(但不是捏缩放)?

谢谢你

4

4 回答 4

3

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)

于 2016-02-12T14:15:01.810 回答
1

尝试这个 :

  [googleMapView.settings setAllGesturesEnabled:NO];
于 2013-08-19T18:52:04.423 回答
0

安装您自己的 Tapgesturerecognizer 并使其接收双击。这样它就不会被提供给谷歌地图。

于 2013-11-03T09:46:22.823 回答
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
        }
    }
}
于 2018-08-06T04:10:15.827 回答