This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) { | |
let center = mapView.region.center | |
let latitudeDelta = mapView.region.span.latitudeDelta | |
let topPin = CLLocation(latitude: center.latitude - (latitudeDelta / 2), | |
longitude: center.longitude) | |
let bottomPin = CLLocation(latitude: center.latitude + (latitudeDelta / 2), | |
longitude: center.longitude) | |
let centerLocation = CLLocation(latitude: center.latitude, | |
longitude: center.longitude) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fetchMapLessons(around: CLLocation, | |
within: Double, | |
_ completionHandler: @escaping ([Any]?) -> Void) { | |
let query = PFQuery(className: "ObjectClass") | |
.addAscendingOrder("date") | |
.whereKey("location", | |
nearGeoPoint: PFGeoPoint(location: around), | |
withinKilometers: within) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fetchMapLessons(_ completionHandler: @escaping ([ObjectModel]?) -> Void) { | |
let query = PFQuery(className: "ObjectClass") | |
.addAscendingOrder("date") | |
query.findObjectsInBackground { (objects, error) in | |
guard let obj = objects else { | |
completionHandler(nil) | |
return | |
} |