【问题标题】:Open map with safari or maps使用 safari 或地图打开地图
【发布时间】:2012-04-06 00:58:57
【问题描述】:

我需要用户选择是否要使用 Safari 或地图应用程序打开地图,但问题是我是否这样做:

NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirflg=d", location.coordinate.latitude, location.coordinate.longitude, destinationLatitude, destinationLongitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

或相同:

[NSString stringWithFormat:@"maps://maps.google.com/maps?

他们都打开地图(我猜是因为 Safari 重定向到地图)

有什么办法可以强制safari打开吗?

【问题讨论】:

标签: iphone ios


【解决方案1】:

我认为您不能强制 Safari 打开 maps.google.com 网址。 Apple's documentation 表示如果地图不可用,Safari 将打开它,否则会将这些 URL 发送到地图。将用户发送到地图的甚至不是 Safari,而是 UIApplication 类。如果您指定 https 协议,您会看到差异——这样它会打开 Safari,然后将您踢入地图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-19
    • 2014-09-12
    • 2018-05-09
    • 2015-06-10
    • 1970-01-01
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多