在GoogleMap iOS Swift上触摸结束事件

Vip*_*egi 2 ios google-maps-sdk-ios swift xcode8

我正在尝试使用一些UIView在Google Map上工作.我的要求是:如果我触摸MapView,其中一个UIView将消失(动画)并且它将一直消失,直到我从MapView释放触摸.我设法使用以下代码在触摸MapView时从屏幕上消失了UIView:

func mapView(_ mapView: GMSMapView, didLongPressAt 
coordinate: CLLocationCoordinate2D) {
self.animate()
}

func mapView(_ mapView: GMSMapView,
idleAt position: GMSCameraPosition) {
self.collapse()
}

func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
//
}

func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
Run Code Online (Sandbox Code Playgroud)

在拖动地图并释放{触摸 - >拖动 - >提升}时,我可以使用idleAt检测手指提升.但是如果我{触摸 - >按住 - >提升}我无法检测到任何东西.例如,你可以考虑Uber或Ola app MapView

Vin*_*gan 7

您可以使用GoogleMaps GMSMapViewDelegate:

mapView.delegate = self
Run Code Online (Sandbox Code Playgroud)

这将在Google地图开始移动和闲置时调用.

func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
//
}

// Touch drag and lift
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
//
}

// Touch and lift
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
    print("yes")
}
Run Code Online (Sandbox Code Playgroud)