Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在iOS应用程序中打开Google地图_Ios_Iphone_Objective C_Google Maps_Viewdidload - Fatal编程技术网

无法在iOS应用程序中打开Google地图

无法在iOS应用程序中打开Google地图,ios,iphone,objective-c,google-maps,viewdidload,Ios,Iphone,Objective C,Google Maps,Viewdidload,我正在尝试通过以下操作在我的应用程序中启动Google Maps iOS应用程序: - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Google Map"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:

我正在尝试通过以下操作在我的应用程序中启动Google Maps iOS应用程序:

- (void)viewDidLoad
{
    [super viewDidLoad];        
    self.title                  =   @"Google Map";
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:
                                                @"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]];
}
然而,该应用程序根本没有启动谷歌地图iOS。我确实安装了谷歌地图iOS

我错过了什么

有人能帮我吗

谢谢。

试试这个

 CLLocationCoordinate2D coordinate = COORDINATE;

// Open Google Maps application
 if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) {

    NSString *daddr = [NSString stringWithFormat:@"%g,%g",coordinate.latitude, coordinate.longitude];

    NSString *urlString = nil;

    BOOL showQuery = YES;
    if (showQuery) {
        // Query
        urlString = [NSString stringWithFormat:@"comgooglemaps://?q=%@",daddr];
    } else {
        // Directions
        urlString = [NSString stringWithFormat:@"comgooglemaps://?saddr=&daddr=%@", daddr];
    }

    NSURL *url = [NSURL URLWithString:urlString];
    [[UIApplication sharedApplication] openURL:url];
}
试试这个

 CLLocationCoordinate2D coordinate = COORDINATE;

// Open Google Maps application
 if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) {

    NSString *daddr = [NSString stringWithFormat:@"%g,%g",coordinate.latitude, coordinate.longitude];

    NSString *urlString = nil;

    BOOL showQuery = YES;
    if (showQuery) {
        // Query
        urlString = [NSString stringWithFormat:@"comgooglemaps://?q=%@",daddr];
    } else {
        // Directions
        urlString = [NSString stringWithFormat:@"comgooglemaps://?saddr=&daddr=%@", daddr];
    }

    NSURL *url = [NSURL URLWithString:urlString];
    [[UIApplication sharedApplication] openURL:url];
}

您需要在project Info.plist中包含comgooglemaps url方案。我建议退房。它可以帮助您轻松地打开谷歌地图、Waze、苹果地图、公交应用程序、Citymapper和Navigon

您需要在project Info.plist中包含comgooglemaps url方案。我建议退房。它可以帮助您轻松地打开谷歌地图、Waze、苹果地图、公交应用程序、Citymapper和Navigon

当您在Safari的地址栏中键入相同的URL时,它是否起作用?不,它在Safari的地址栏中不起作用。我正在关注教程,这很有趣,将URL粘贴到Safari对我来说很好。你是否可能将iOS 5地图应用程序与官方的谷歌地图iOS应用程序混淆?我试过了,但不起作用。请查看我尝试过的内容。您必须在安装应用程序的设备上执行此操作。当您在Safari的地址栏中键入相同的URL时,它是否起作用?不,它在Safari的地址栏中不起作用。我正在关注教程,这很有趣,将URL粘贴到Safari对我来说很好。你是否可能将iOS 5地图应用程序与官方的谷歌地图iOS应用程序混淆?我试过了,但没有工作。请查看我尝试过的内容。您必须在安装应用程序的设备上执行此操作。