Touch end event on GoogleMap iOS Swift

2.7k Views Asked by At

I am trying to work on Google Map with some UIView. My requirement is : If I touch the MapView, one of UIView will disappear(animated) and it will remain disappear until I release the touch from MapView. I managed to disappear the UIView from screen on touching the MapView using the below code :

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) {

On dragging map and release { Touch --> Drag --> Lift } I can detect Finger Lift using idleAt. But I couldn't detect with anything if I { Touch --> hold --> Lift }. You can consider Uber or Ola app MapView for example

1

There are 1 best solutions below

8
On

You can use GoogleMaps GMSMapViewDelegate:

mapView.delegate = self

This will call when Google map start moving and idle.

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")
}