使用当前位置打开地图应用程序& iOS 5中的路线

时间:2012-06-12 05:15:40

标签: google-maps ios5 ios4 core-location

您好我尝试使用此功能打开当前位置的地图应用,并获取指示我为路线指定的任何内容。当我点击iPhone上的按钮时,没有任何反应,但它被点击了。我做错了什么?

NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=Current+Location&daddr=%@ %@ %@ %@",
                     streetString , cityString, stateString, zipString];
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];

1 个答案:

答案 0 :(得分:0)

确保使用stringByAddingPercentEscapesUsingEncoding

转义NSString
NSString *url = [NSString stringWithFormat: @"http://maps.google.com/mapssaddr=Current+Location&daddr=%@ %@ %@ %@", streetString , cityString, stateString, zipString];
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];