0

내가 필요한 것은 Google지도 앱에 작업 시트 위임을 사용하여 내 앱에서 위도와 경도 정보를 보내고 제공된 위도 lng 매개 변수를 사용하여 Google지도에서 핀 (마커) 여기 ios actionsheet 외부 Google지도 앱 및 핀 마커를 호출합니다.

당신이 볼 수 있듯이, 내가 빨간 핀 애플지도가 성공적으로 drawed 가지고 있지만 내가 comgooglemap를 사용하여 구글 맵에서 동일한 핀을 그리는 방법을 잘 모릅니다 내 코드

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
    //coordinates for the place we want to display 
    CLLocationCoordinate2D mosqueLocation = CLLocationCoordinate2DMake(lat,lng); 
    if (buttonIndex==0) { 
     //Apple Maps, using the MKMapItem class 
     MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:mosqueLocation addressDictionary:nil]; 
     MKMapItem *item = [[MKMapItem alloc] initWithPlacemark:placemark]; 
     item.name = navBarTitle.title; 
     [item openInMapsWithLaunchOptions:nil]; 
    } else if (buttonIndex==1) { 
     //Google Maps 
     //construct a URL using the comgooglemaps schema 
     NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?center=%f,%f",mosqueLocation.latitude,mosqueLocation.longitude]]; 
     if (![[UIApplication sharedApplication] canOpenURL:url]) { 
      NSLog(@"Google Maps app is not installed"); 
       } else { 
      [[UIApplication sharedApplication] openURL:url]; 
     } 
    } 
} 

입니다 urlscheme.

위도와 LNG 제공, 그냥 좌표에 마커를 표시하는

+0

FYI -이 질문은 'UIActionSheet'와는 전혀 관련이 없습니다. 질문은 실제로 Google지도에 핀을 그리는 것입니다. – rmaddy

+0

예, 어떤 도움이 될 것입니다 – seph

+0

다른 한 가지 이유 - 위임 방법에서 "comgooglemaps"URL을 열 수 있는지 확인하는 이유는 무엇입니까? 액션 시트의 버튼을 제공하기 전에 코드가이를 확인해야합니다. – rmaddy

답변

4

검색을 추가 덕분에, 더 나은 코드 예제, 제안은 매우 도움이 될 것입니다, 추첨을 만들기 위해 구글 맵 응용 프로그램에 보낼 필요 그 위치 :

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) { 
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?center=%f,%f&q=%f,%f",mosqueLocation.latitude,mosqueLocation.longitude, mosqueLocation.latitude,mosqueLocation.longitude]]; 
    [[UIApplication sharedApplication] openURL:url]; 
} else { 
    NSLog(@"Can't use comgooglemaps://"); 
} 
+0

멋진 솔루션! 공장! – seph

+0

@Cornelius는 주석의 이름을 쓸 수 있습니까? – erdemgc

+0

@erdemgc 아니, 나는 그렇게 생각하지 않는다. 다음은 Google지도 URL 스키마의 문서입니다. https://developers.google.com/maps/documentation/ios/urlscheme – Cornelius

관련 문제