Last active
December 5, 2018 15:26
-
-
Save charvoa/aa4adb6de4187196382e778c3c3fec75 to your computer and use it in GitHub Desktop.
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) | |
let distance = max(topPin.distance(from: centerLocation), | |
bottomPin.distance(from: centerLocation)) | |
reloadData() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment