简体   繁体   中英

google maps disabled zoom when I implement tap gesture recogniser?

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM