2013-05-30 2 views
7

일부 클러스터링 함수를 만들기 위해 GMSMapView를 확장하려고합니다. 사용자가지도를 이동하여 클러스터 렌더링을 비활성화하고 완료 할 때 다시 활성화 할 때를 감지해야합니다.GMSMapView는 한 번만 실행됩니다.

나는 touchesbegan과 touchesended하지만 touchesbegan은 한 번만 호출됩니다. hittest를 재정의 한 후 GMSVectorMapView가 GMSMapView를 처리하는 것을 볼 수 있었고이 함수의 반환을 변경하면지도가 이동하지 않습니다.

이 이벤트를 캡처하거나 사용자가지도와 상호 작용할 때 어떤 조치를 취할 수있는 방법이 있습니까?

최고 감사합니다, 말론 피나 Tojal

답변

10

는 내가 완전히 감지 할 필요가 건 드리면 이해 확실하지 않다 또는 왜/당신이 그들을 발견해야하는지. 그러나 touchesbegan 때문에 GMSMapView 위에 사용자 팬 동작을 감지하는 비슷한 문제가있었습니다. 한 번만 호출되었습니다.

나는 자신의 "현재 위치"버튼을 사용하여 사용자가지도의 위치를 ​​켜고 끌 수 있도록 토글 할 수 있습니다. 나는 사용자가 언제지도의 패닝 수신을 방해하지 않고지도를 "패닝"했는지 알아야했습니다 (여전히지도가 잘 보이길 원했습니다).

// Creates Map centered at current location 
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:theLocationManager.location.coordinate.latitude 
                 Longitude:theLocationManager.location.coordinate.longitude 
                  zoom:15]; 
theMapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
theMapView.myLocationEnabled = YES; 
theMapView.delegate = self; 
theMapView.camera = camera; 
self.view = theMapView; 

가 그럼 난 팬 제스처 인식기를 작성 theMapView의 제스처 인식기 속성에 추가 :

첫째,지도를 만들었습니다. 나는 선택 방법 self에 목표를 설정해야했다 didPan:

// Watch for pan 
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget: self action:@selector(didPan:)]; 
theMapView.gestureRecognizers = @[panRecognizer]; 
마지막으로, 같은 주요 파일에, 나는 반응하는 didPan: 방법을 구현

때 사용자 팬 :

- (void) didPan:(UIPanGestureRecognizer*) gestureRecognizer 
{ 
    NSLog(@"DID PAN"); 
    // React here to user's pan 
} 
+0

정말 완벽한 답변입니다. 감사합니다 +1 –

1

최신 업데이트 Google지도에 대리자 메소드가 있습니까?