繁体   English   中英

实现点击手势识别器时,谷歌地图禁用缩放功能?

[英]google maps disabled zoom when I implement tap gesture recogniser?

我的IOS应用程序使用的是Google Maps sdk,当用户在地图上单击时,需要更改标记位置。 因此,当我实现此功能时,效果很好,但是当地图上出现双重提示时,缩放功能就停止了。 这是我的代码:

// 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]; }

因此,我的问题是如何在不丢失缩放功能的情况下使单击手势识别器正常工作?

而不是添加自己的UITapGesture,您可以使用Google提供的委托方法

- (void)mapView:(GMSMapView *)amapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate

然后,您可以将标记更新为给定的坐标。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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