I am creating a map based application which, as many do, incorporates a button which will in theory re-center the map on the user's location and zoom in on the user (if the zoom level has changed). Currently, in viewDidLoad() I have the line:
mapView.setUserTrackingMode(MKUserTrackingMode.followWithHeading, animated: true)
which does successfully set the user tracking mode and a comfortable zoom level. Then, when the user pans, the tracking mode is set to None as the documentation states, which is what I want. However, following panning, when an IBAction is called from a button which contains this exact same line, the mapview will recenter on the user's location and reinstate tracking, but will not zoom back in on the user unless the mapView has been zoomed out significantly (to the state or country level). What can I do to fix this issue? I have tried setting the region manually based on the users location, but have found this interferes with the user tracking. (I set the IBAction to call the following function)
func centerMapOnLocation(location: CLLocation, animated: Bool){
let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate, 1000, 1000)
mapView.setRegion(coordinateRegion, animated: animated)
}
But calling this function seems to reset the user tracking mode to none, whether the user tracking mode is changed prior to or following the function call. Thanks for the help!