4

我想在我的 Iphone 应用程序中打开设备映射以在源和目标之间绘制路径,如下图所示。

在此处输入图像描述

如何在我的 Iphone 应用程序中打开设备映射,如上图?

4

1 回答 1

3

使用以下代码打开地图应用程序,

        NSString *url;

        if([[[UIDevice currentDevice] systemVersion] compare:@"6.0" options:NSNumericSearch] == NSOrderedAscending)
        {
            url = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%@,%@&saddr=%@,%@",[dict objectForKey:@"latitude"],[dict objectForKey:@"longitude"],currentLat,currentLong];

        }
        else
        {
            url = [NSString stringWithFormat:@"http://maps.apple.com/maps?daddr=%@,%@&saddr=%@,%@",[dict objectForKey:@"latitude"],[dict objectForKey:@"longitude"],currentLat,currentLong];
        }
        if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:url]])
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
        }

iOS 6.0 及以上版本有苹果地图应用程序,iOS 较低版本你必须打开谷歌地图应用程序。在网址中,

daddr=%@,%@&saddr=%@,%@

daddr是目的地址,saddr是源地址。

于 2013-03-12T13:45:20.293 回答