Reputation: 539
I'm using Google Maps sdk for my IOS app, and I needed to change a marker location when the user do a single tap on the map. So when I implemented this feature it worked well, but the zoom feature when double clic on the map stopped. Here is my code :
// on viewDidLoad ()
//...
UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleGesture:)];
tgr.numberOfTapsRequired = 1;
tgr.numberOfTouchesRequired = 1;
[mask addGestureRecognizer:tgr]; //mask here is a UiImageView above the map, userInteraction is enabled to enable gesture recogniser
- (void)handleGesture:(UITapGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state != UIGestureRecognizerStateEnded)
return;
CGPoint touchPoint = [gestureRecognizer locationInView:mapView];
CLLocationCoordinate2D coordinate =
[mapView.projection coordinateForPoint: touchPoint];
[marker setPosition:coordinate]; }
So my question is how to get single tap gesture recogniser working, in the same time not losing the zoom feature ?
Upvotes: 0
Views: 569
Reputation: 439
instead of adding your own UITapGesture you can use google provided delegate method
- (void)mapView:(GMSMapView *)amapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
And then you can update your marker to given coordinate.
Upvotes: 0