2016-08-07 2 views
0

마커의 표준과 동일한 정보 상자가 내 폴리 라인을 탭할 때 나타나려고합니다. 선이 도청 될 때 NSLog을 출력했지만 지금은 NSLog 대신 infobox를 표시해야합니다. 나는 몇몇 자바 스크립트 예제를 보았지만 객관적인 것들은 보지 못했다.탭 이벤트 발생시 사용자 정의 정보창

- (void)loadView { 

// Create a GMSCameraPosition 
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:37.551927 
                 longitude:-77.456292 
                  zoom:18]; 
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(37.551709, -77.456510); 
mapView.settings.myLocationButton = YES; 
mapView.myLocationEnabled = YES; 
self.view = mapView; 
mapView.delegate = self; 

GMSMutablePath *path = [GMSMutablePath path]; 
[path addCoordinate:CLLocationCoordinate2DMake(37.552243, -77.457415)]; 
[path addCoordinate:CLLocationCoordinate2DMake(37.551054, -77.455443)]; 

GMSPolyline *polyline = [GMSPolyline polylineWithPath:path]; 

UILabel *myLabel = [[UILabel alloc] init]; 

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(labelTapped)]; 
tapGestureRecognizer.numberOfTapsRequired = 1; 
[myLabel addGestureRecognizer:tapGestureRecognizer]; 
myLabel.userInteractionEnabled = YES; 

polyline.spans = @[[GMSStyleSpan spanWithColor:[UIColor greenColor]]]; 
polyline.strokeWidth = 5.f; 
polyline.tappable = true; 
polyline.map = mapView; 

} 

- (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay 
{ 
    NSLog(@"in didTapOverlay"); 
} 

@end 

답변

0

iOS지도 설명서에서 Events 가이드를 확인하십시오. 여기

- (void)loadView { 
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285 
                  longitude:103.848 
                   zoom:12]; 
    GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
    mapView.delegate = self; 
    self.view = mapView; 
} 

#pragma mark - GMSMapViewDelegate 

- (void)mapView:(GMSMapView *)mapView 
    didTapAtCoordinate:(CLLocationCoordinate2D)coordinate { 
    NSLog(@"You tapped at %f,%f", coordinate.latitude, coordinate.longitude); 
} 

GMSMapViewDelegate의 사용을 보여주는 SO thread입니다 : 다음은 목표 - C의 조각입니다

1.conform GMSMapViewDelegate 프로토콜을.

@interface YourViewController() <GMSMapViewDelegate> 
// your properties 
@end 
2.set your mapView_ delegate. 

mapView_.delegate = self; 
3.implement the GMSMapViewDelegate method 

- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker { 
    // your code 
} 

추가 : marker.userData이 유용합니다. 당신은 그것에 필요한 데이터를 설정하고 그것을 사용할 수 있습니다 - mapView:didTapInfoWindowOfMarker: