User Location & Array of CLCircularRegions
User Location & Array of CLCircularRegions
- Subject: User Location & Array of CLCircularRegions
- From: "Eric E. Dolecki" <email@hidden>
- Date: Thu, 27 Jul 2017 18:38:02 +0000
I am trying to get around the limit of 20 monitored regions for iOS. So, I
have an array of all regions (CLCircularRegions) and I have the user's
location. Based on that I want to unregister all regions, and then find the
closest 20 of them. How exactly should I do this?
var monitoredRegions:[CLCircularRegion] = []
...
monitoredRegions.removeAll()
...
// within a loop
let thisRegion = CLCircularRegion(center: centerLocation, radius: radius,
identifier: title)
monitoredRegions.append(thisRegion)
...
let location: CLLocation = CLLocation(latitude: self.myMapView.userLocation.
coordinate.latitude, longitude: self.myMapView.userLocation.coordinate.
longitude)
for region in self.monitoredRegions {
let fenceLocation = CLLocation(latitude: region.center.latitude,
longitude: region.center.longitude)
let distance = location.distance(from: fenceLocation)
print("Distance: \(region.identifier): \(distance)m")
*// Push into a dictionary and then after this for loop, later
sort based on a key? Then use that to re-index the monitoredRegions?*
}
Thanks,
Eric
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden