此功能用于检查多边形内部或外部的纬度或经度。
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。因此参数将像纬度,经度,准确度 E.g:
func withinAccuracy(latitude:Double,longitude:Double,accuracy:Double){
//....
}
答案 0 :(得分:0)
看看这个功能
GMSGeometryIsLocationOnPathTolerance(_ point: CLLocationCoordinate2D, _ path: GMSPath, _ geodesic: Bool, _ tolerance: CLLocationDistance) -> Bool
它完全符合您的要求。 link