Skip to content

Instantly share code, notes, and snippets.

@Busta117
Last active August 29, 2015 14:20
Show Gist options
  • Save Busta117/3ab5df699a6adf7d6d01 to your computer and use it in GitHub Desktop.
Save Busta117/3ab5df699a6adf7d6d01 to your computer and use it in GitHub Desktop.
func centerMapWithCoords(coordsArr:[CLLocationCoordinate2D]){
var zoomRect:MKMapRect = MKMapRectNull;
for coord:CLLocationCoordinate2D in coordsArr {
var annotationPoint: MKMapPoint = MKMapPointForCoordinate(coord)
var pointRect:MKMapRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0)
zoomRect = MKMapRectUnion(zoomRect, pointRect)
}
mapView.setVisibleMapRect(zoomRect, edgePadding:UIEdgeInsetsMake(150, 30, 30, 30), animated:false)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment