如何检查一个位置是否在多边形的“精度”范围内。如果该功能的精度为30m

问题描述:

该功能用于检查多边形内部或外部的纬度或经度。如何检查一个位置是否在多边形的“精度”范围内。如果该功能的精度为30m

func isAvalibleinsidePolygone{ 
      let latitude = lat?.text 
      let longitude = lon?.text 
      if latitude != "" && longitude != "" { 
       //   pathOfPolygon.removeAllCoordinates() 
       for p in places { 
        pathOfPolygon.add(p.coordinate) 
       } 
    ifGMSGeometryContainsLocation(CLLocationCoordinate2DMake(Double(latitude!)!, Double(longitude!)!), pathOfPolygon, true) { 
        alert(title:`enter code here` "YEAH!!!", msg: "You are inside the polygon") 

       } else { 
       alert(title: "OPPS!!!", msg: "You are outside the polygon") 
       } 
      } 
     } 

但即使我想检查一个位置是否在多边形的“准确度”内 - 例如,如果该功能的准确性为30米,则距多边形30米范围内的任何位置都应该返回true。所以参数是经度,纬度,精度 E.g:

func withinAccuracy(latitude:Double,longitude:Double,accuracy:Double){ 
//.... 
} 
+0

它为我工作。谢谢 –

+0

我很高兴听到这个消息。发表评论作为答案,所以你可以接受他们。 –

看一看功能它正是你想要的 GMSGeometryIsLocationOnPathTolerance(_ point: CLLocationCoordinate2D, _ path: GMSPath, _ geodesic: Bool, _ tolerance: CLLocationDistance) -> Boollink