当我实现点击手势识别器时谷歌地图禁用缩放?

时间:2014-08-28 07:00:36

标签: ios google-maps zoom

我正在使用Google Maps sdk作为我的IOS应用,当用户在地图上点击一下时,我需要更改标记位置。因此,当我实现此功能时,它运行良好,但是当地图上的双clic停止时,缩放功能。这是我的代码:

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

所以我的问题是如何让单击手势识别器工作,同时不会丢失缩放功能?

1 个答案:

答案 0 :(得分:1)

您可以使用Google提供的委托方法

,而不是添加自己的UITapGesture
- (void)mapView:(GMSMapView *)amapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate

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