How to invoke iPhone Maps for Directions with Current Location as Start Address

后端 未结 16 1657
一整个雨季
一整个雨季 2020-12-02 03:53

I know it\'s possible to start the iPhone maps application by calling openURL on a google maps URL with parameters saddr and daddr wit

16条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 04:49

    NSString* addr = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=Current Location&saddr=%@",startAddr];
    NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [[UIApplication sharedApplication] openURL:url];
    [url release];
    

    This works but only when the iPhone/iPod language is set in English. If you want to support other languages you'll have to use a localized string to match the Maps bookmark name.

提交回复
热议问题