【问题标题】:How to embed the Google Maps iPhone app within my own native iphone application?如何在我自己的原生 iPhone 应用程序中嵌入 Google Maps iPhone 应用程序?
【发布时间】:2013-08-14 11:43:33
【问题描述】:

Apple 开发者文档解释说,如果您在web page 中放置一个链接,然后在 iPhone 上使用 Mobile Safari 时单击它,则作为 iPhone 标准提供的 Google 地图应用程序将启动。

如何在我自己的本地 iPhone 应用程序(即不是通过 Mobile Safari 的网页)中启动具有特定地址的同一 Google 地图应用程序,就像在“通讯录”中点击地址启动地图一样?

【问题讨论】:

    标签: iphone google-maps


    【解决方案1】:

    对于 iOS 6.1.1 及更低版本,使用 UIApplication 的 openURL 方法。它将执行正常的 iPhone 神奇 URL 重新解释。所以

    [someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]]
    

    应该调用 Google 地图应用程序。

    从 iOS 6 开始,您将调用 Apple 自己的地图应用程序。为此,使用您要显示的位置配置一个 MKMapItem 对象,然后向其发送 openInMapsWithLaunchOptions 消息。要从当前位置开始,请尝试:

    [[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil];
    

    为此,您需要与 MapKit 相关联(我相信它会提示您访问位置)。

    你也可以使用

    UIApplication *app = [UIApplication sharedApplication];
    [app openURL:[NSURL URLWithString: @"http://maps.google.com/maps?q=London"]];
    

    要在特定坐标打开 Google 地图,请尝试this 代码:

    NSString *latlong = @"-56.568545,1.256281";
    NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?ll=%@",
    [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    

    您可以将 latlong 字符串替换为 CoreLocation 中的当前位置。

    您还可以使用 (“z”) 标志指定缩放级别。值为 1-19。这是一个例子:

    [[UIApplication sharedApplication] openURL:[NSURL         URLWithString:@"http://maps.google.com/maps?z=8"]];
    

    【讨论】:

    • 这段代码:codefor (int i = 0; i result[j]) { int temp = result[i];结果[i] = 结果[j];结果[j] = 温度; } } } code 不是选择排序的工作方式。这是冒泡排序 类名 public class Main { 最好命名为 SelectionSort(或 BubbleSort,因为从技术上讲就是这样)。 upmodels 您的 displayArray 方法缺少一些大括号。建议始终使用牙套。即使是单线。
    猜你喜欢
    • 2010-09-07
    • 1970-01-01
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    • 2013-06-08
    • 2011-04-11
    • 2011-01-04
    • 1970-01-01
    相关资源
    最近更新 更多