2014-08-28 87 views
0

我爲我的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]; } 

所以我的問題是如何得到單擊手勢識別器的工作中,同時不失縮放功能?

回答

1

,而不是添加自己UITapGesture你可以使用谷歌提供的委託方法

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

然後給定的座標,您可以更新您的標記。