Swift 如何检查某个位置是否位于;“准确度”;多边形的精度-例如,如果函数的精度为30m

Swift 如何检查某个位置是否位于;“准确度”;多边形的精度-例如,如果函数的精度为30m,swift,swift3,google-maps-sdk-ios,Swift,Swift3,Google Maps Sdk Ios,此功能用于检查经纬度是否在多边形范围之内或之外 func isAvalibleinsidePolygone{ let latitude = lat?.text let longitude = lon?.text if latitude != "" && longitude != "" { // pathOfPolygon.removeAllCoordin

此功能用于检查经纬度是否在多边形范围之内或之外

 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")
                }
            }
        }
但即使我想检查一个位置是否在多边形的“精度”范围内-例如,如果函数的精度为30m,则在多边形30m范围内的任何位置仍应返回true。所以参数将像纬度,经度,精度 例如:


看看这个函数
gmsgeometryLocationPathTolerance(uu点:CLLocationCoordinate2D,uu路径:GMSPath,uu测地:Bool,uuu公差:CLLocationDistance)->Bool
它完全满足您的需求

这对我有用。谢谢,听到这个消息我很高兴。将评论作为答案发布,以便您可以接受。
func withinAccuracy(latitude:Double,longitude:Double,accuracy:Double){
//....
}