以下代码无法在iPhone上打开Google地图应用,并且从一个点导航到另一个点,但是当我将同一个URL复制到桌面浏览器时,它会打开谷歌地图。
如何在Google地图应用中开始导航?
if([[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}
答案 0 :(得分:0)
您可以从有关可用网址方案的Google文档开始。具体来说,有一个关于如何add navigation到您的应用的部分。
答案 1 :(得分:0)
试试这个..
NSString *escapedString = [strUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
strUrl=[escapedString stringByReplacingOccurrencesOfString:@"%20" withString:@"+"];
if ([[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]])
{
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[@"comgooglemaps://?" stringByAppendingString:strUrl]]];
}