GMSMapView touched only once

I am trying to extend GMSMapView to create some clustering functions, and I need to determine when the user starts moving the map to turn off the rendering of the cluster, and turn it back on when he finishes it.

I overestimated the touch and touch, but the touch is called only once. After overriding hittest, I was able to see that GMSVectorMapView handles GMSMapView touches, and if I change the return of this function, the map does not move.

Is there a way to capture these events or give some action when the user interacts with the map.

Best regards, Marlon Pina Tojal

+7
source share
2 answers

I'm not sure I fully understand what strokes you need to detect or why / how you need to detect them. However, I had a similar issue detecting user gestures gestures on top of the GMSMapView due to touchhesbegan: only called once.

I had my own button “Current Location”, which allows the user to switch the centering of the map by their location on / off. I needed to find out when the user “pans” the map without interrupting the reception of the panning map (I still wanted the map to also be paned).

First I created a map:

// Creates Map centered at current location GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:theLocationManager.location.coordinate.latitude Longitude:theLocationManager.location.coordinate.longitude zoom:15]; theMapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; theMapView.myLocationEnabled = YES; theMapView.delegate = self; theMapView.camera = camera; self.view = theMapView; 

Then I created a gesture recognizer and added it to theMapView gesture recognition attribute. I set the goal self using the didPan: selector didPan:

 // Watch for pan UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget: self action:@selector(didPan:)]; theMapView.gestureRecognizers = @[panRecognizer]; 

Finally, in the same main file, I applied the didPan: method to respond when the user clicks:

 - (void) didPan:(UIPanGestureRecognizer*) gestureRecognizer { NSLog(@"DID PAN"); // React here to user pan } 
+10
source

Last update is delegate method on google maps

 - (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate; 
+1
source

All Articles