在swift中寻找GMSPath类的contains(:latitude:longitude)方法

时间:2017-10-31 11:28:02

标签: ios swift google-maps path google-maps-sdk-ios

我正在开发公交车tarcking app.I用GMSPath类绘制公交车道。我需要检查具体(纬度,经度)是否在该路径中。我用google搜索,但找不到像contains这样的方法(:纬度:经度)检查我想要的东西。我也看了google documentation 如果您对我如何做到这一点有任何了解,请与我分享您的经验。

1 个答案:

答案 0 :(得分:0)

总线可能稍微偏离路径,因此您可能需要添加一些容差而不是严格限制。请查看GMSGeometricUtils.h,更具体地说:

/**
 * Returns whether |point| lies on or near |path|, within the specified |tolerance| in meters.
 * |path| is composed of great circle segments if |geodesic| is YES, and of rhumb (loxodromic)
 * segments if |geodesic| is NO.
 *
 */
BOOL GMSGeometryIsLocationOnPathTolerance(CLLocationCoordinate2D point,
                                          GMSPath *path,
                                          BOOL geodesic,
                                          CLLocationDistance tolerance);