【发布时间】:2017-06-26 03:03:21
【问题描述】:
这个功能是检查纬度或经度是否在多边形内部或外部。
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。所以参数会像纬度,经度,准确度 例如:
func withinAccuracy(latitude:Double,longitude:Double,accuracy:Double){
//....
}
【问题讨论】:
-
它对我有用。谢谢
-
我很高兴听到这个消息。将评论作为答案发布,以便您接受。
标签: swift swift3 google-maps-sdk-ios