【问题标题】:objective c - starting Apples Maps or Google Maps on MapView [closed]目标 c - 在 MapView 上启动 Apples Maps 或 Google Maps [关闭]
【发布时间】:2013-04-30 10:50:25
【问题描述】:

我想知道如何从我的应用启动其他应用。

这里的情况:

我有一个指向特定经度/纬度的 MapView。

我想让用户有机会使用这两个应用程序自己导航(谷歌地图或苹果地图)到坐标。

那我该怎么办:

  1. 启动另一个应用程序(在此示例中为 GoogleMaps 或 Maps),首先检查安装了哪个应用程序
  2. 向他们传递经度/纬度坐标?

我希望这足够清楚..

【问题讨论】:

  • 你想说什么? :-O
  • 感谢投票,更新问题..
  • 你有没有努力寻找答案?

标签: iphone objective-c google-maps maps mkmapview


【解决方案1】:

handleopenurl.com 是一个很好的网站,可以直接从您的应用程序中获取打开应用程序的链接。如果你在那里搜索谷歌地图,它会显示一个类似这样的链接,其中仅包含链接中的纬度/经度。

 routeString = [NSString stringWithFormat:@"comgooglemaps://?daddr=%f,%f&saddr=%f,%f&mrsp=0&ht=it&ftr=0", contactPosition.latitude, contactPosition.longitude, myPosition.latitude, myPosition.longitude];

(您还需要Google Maps SDK 才能合并到您的应用中。)

Now to check if Google Maps app is installed or not you will use canOpenURL method to determine that. If app is not installed it will open Google Maps in Safari web browser.

if([[UIApplication sharedApplication]canOpenURL:routeString]){

                [[UIApplication sharedApplication] openURL:routeString];
            }
            else{
                self.urlGlobal=[NSURL URLWithString:@"http://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&sensor=false"];
                [[UIApplication sharedApplication]openURL:self.urlGlobal];
            }

【讨论】:

  • 该网站和代码的ty!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-19
  • 2012-11-21
  • 2012-06-11
  • 1970-01-01
  • 2022-12-02
相关资源
最近更新 更多