【问题标题】:Get direction of User by CLLocation通过 CLLocation 获取用户的方向
【发布时间】:2013-04-03 14:56:43
【问题描述】:

您好,我正在开发 GPS ios 应用程序。

我想在 Circle 上显示用户的位置,如图所示。

用户在中心。

我想在正确的方向上显示他朋友的位置。

我已经知道了两个用户的经度和纬度。

但是我怎样才能得到其他用户的方向呢?

是否可以使用方位角?

我通过这段代码得到两次使用之间的距离

CLLocation *locA = [[CLLocation alloc] initWithLatitude:Latitude longitude:Longitude];
CLLocation *locB = [[CLLocation alloc] initWithLatitude:app.lat longitude:app.lag];
CLLocationDistance distance = [locB distanceFromLocation:locA];

感谢您的帮助!!

【问题讨论】:

  • @RDC 我已经有两个位置之间的距离。我想要这个位置之间的方向。

标签: iphone ios gps location angle


【解决方案1】:

您可以使用两种方法来做到这一点:
1.

CLLocationCoordinate2D start = { c_lat, c_long };
CLLocationCoordinate2D destination = { [[dic valueForKey:@"business_lat"]doubleValue], [[dic valueForKey:@"business_long"]doubleValue] };

NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f&",start.latitude, start.longitude, destination.latitude, destination.longitude];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];

2.

使用谷歌API

在 API 中你只需要传递源名称和目的地名称

希望这有帮助....

【讨论】:

  • 由此我只能在 GOOGLE POINT 中显示该点。我想在我的 UI 中显示它,如图所示。
  • @PriyankGandhi :只需解析 google api 响应并根据您的选择设置数据。不要忘记传递您的出发地和目的地。
  • @PriyankGandhi:请检查两个答案。
  • 我没有来源和目的地。我有两组人的经度和纬度,不断更新
  • @PriyankGandhi:使用第一个答案
【解决方案2】:

question 描述了如何使用 hasrsine 函数计算方位

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-26
    • 2022-06-14
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    相关资源
    最近更新 更多