티스토리 뷰

반응형

iOS 다음 지도 길찾기 연동 및 설치되어 있지 않을 경우 다음지도 앱스토어로 이동 처리.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 다음지도를 통한 길찾기 버튼 클릭 리스너
-(void)goNaverMapClick
{
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:
                                            @"daummaps://route?sp=%f,%f&ep=%f,%f&by=CAR",mainView.userLatitude, mainView.userLongitude,
                                            lat, lon]];
    
    //다음 지도 설치 유무 판단.
    BOOL isInstall = [[UIApplication sharedApplication] canOpenURL:url];
    
    if (isInstall)
    {
        [[UIApplication sharedApplication] openURL:url];
    } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"알 림"
                                                        message:@"다음 지도앱으로 연결합니다. 스토어로 이동하시겠습니까?"
                                                       delegate:self
                                              cancelButtonTitle:@"취소"
                                              otherButtonTitles:@"확인",nil];
        [alert show];
        [alert setTag:100];
    }
}
 
//다음 지도를 설치하겠다고 할 경우 앱스토어 다음지도로 연결.
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag == 100)
    {
        if (buttonIndex == 1)
        {
            //다음 지도 앱스토어로 이동.
            NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/app/id304608425?mt=8"];
            [[UIApplication sharedApplication] openURL:url];
        }
    }
}
 
 
 
 
cs



네이버 지도 길찾기 연동.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    NSURL *naverUrl = [NSURL URLWithString:[NSString stringWithFormat:@"navermaps://?menu=route&routeType=4&elat=%f&elng=%f&etitle=%@", lat, lon, title]];
    
    //네이버 지도 설치 유무 판단.
    BOOL isInstall = [[UIApplication sharedApplication] canOpenURL:naverUrl];
    
    if (isInstall)
    {
        [[UIApplication sharedApplication] openURL:naverUrl];
    } else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"알 림"
                                                        message:@"네이버 지도앱으로 연결합니다. 스토어로 이동하시겠습니까?"
                                                       delegate:self
                                              cancelButtonTitle:@"취소"
                                              otherButtonTitles:@"확인",nil];
        [alert show];
    }
 
 
 
cs


반응형
댓글
반응형