iOS swift-判断当前位置与覆盖物的关系

func PanDuanDangQiangWeiZhi(_ huancheDic:NSDictionary,_ huancheNotice:NSNotification,_ type:Int) -> () {

if gdMapView.userLocation.isUpdating && gdMapView.userLocation.location != nil{

self.gdMapView.setCenter(gdMapView.userLocation.location.coordinate, animated: true)

gdMapView.setZoomLevel(16, animated: true)

gdMapView.rotationDegree = 0.0

isMyLocation = true

let request = AMapReGeocodeSearchRequest()

request.location = AMapGeoPoint.location(withLatitude: CGFloat(gdMapView.userLocation.location.coordinate.latitude), longitude: CGFloat(gdMapView.userLocation.location.coordinate.longitude))

request.requireExtension = true

search.aMapReGoecodeSearch(request)

}

//围栏

self.Yhylatitude = gdMapView.userLocation.location.coordinate.latitude

self.Yhylongitude = gdMapView.userLocation.location.coordinate.longitude

let YHylocation = (CLLocationCoordinate2D(latitude: gdMapView.userLocation.location.coordinate.latitude,longitude: gdMapView.userLocation.location.coordinate.longitude))

let YHylocationPoint = MAMapPointForCoordinate(YHylocation)

//停车

if (self.DianZiWeiLanOverlays != nil) {

for index in 0..

if (self.DianZiWeiLanOverlays[index] is MACircle) {

let tinchecircle: MACircle = self.DianZiWeiLanOverlays[index] as! MACircle

if (MACircleContainsCoordinate(gdMapView.userLocation.location.coordinate, tinchecircle.coordinate, tinchecircle.radius)) {

//                        self.view.makeToast("可以停车", duration: 2)

YhyIsTingCheDian = true

print("可以停车")

break

} else {

//                        self.view.makeToast("不可停车", duration:2);

YhyIsTingCheDian = false

print("不可停车")

}

}

}

for index in 0..

if (self.DianZiWeiLanOverlays[index] is MAPolygon) {

let tinchePolygon: MAPolygon = self.DianZiWeiLanOverlays[index] as! MAPolygon

if (MAPolygonContainsPoint(YHylocationPoint, tinchePolygon.points, tinchePolygon.pointCount)) {

//                        self.view.makeToast("在里面", duration: 2)

YhyIsWeiLan = true

print("在里面")

break

} else {

//                        self.view.makeToast("在外面", duration:2)

YhyIsWeiLan = false

print("在外面")

}

}

}

}

self.panDuanDangQiangWeiZhiPost(huancheDic, huancheNotice, type)

}

你可能感兴趣的:(iOS swift-判断当前位置与覆盖物的关系)