2017-09-27 26 views
0

以下代码无法在iPhone上打开Goog​​le地图应用程序,并且从一点到另一点导航,但是当我将同一个URL复制到桌面浏览器时,谷歌地图。使用Objective-C开始在ios上的多个目的地导航使用Objective-C

如何在Google地图应用中开始导航?

海峡= https://maps.google.com/maps/dir/?api=1&origin=18.606791,73.785611&destination=18.611997,73.971692&waypoints=18.606791,73.785611|18.611997,73.971692|18.465518,74.012204

if([[UIApplication sharedApplication] canOpenURL: 
    [NSURL URLWithString:@"comgooglemaps://"]]) 
{ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; 
} 
+0

Yuvaraj芥兰你能告诉你的代码,你怎么申请? – user3182143

+0

通过这个 - https://stackoverflow.com/questions/41392092/google-maps-directions-url-error-when-adding-multiple-waypoints/41449231#41449231 – user3182143

回答

0

您可以在可用的URL方案的谷歌文档开始。具体来说,有一个关于如何add navigation到您的应用程序的部分。

+0

我已经通过文档我没有得到任何解。 –

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]]]; 
    } 
+0

不,它只打开谷歌地图,但没有显示我输入的位置。 –