我正在开发总线标签应用程序。我用GMSPath类画了公共汽车的道路。我需要检查特定(纬度,经度)是否在该路径中。我用谷歌搜索,但找不到像 contain(:latitude:longitude) 这样的方法来检查我想要什么。我还查看了谷歌文档如果您知道我该如何做到这一点,请与我分享您的经验。
总线可能略微偏离路径,因此您可能需要添加一些容差而不是严格的遏制。看看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);