I'm using MKLocalSearch
to search for certain places like cities or streets in cities to shown them on an MKMapView
I show the placemark like this
let loc = placemark.location! //CLLocation of CLPlacemark
var mapRegion = MKCoordinateRegion()
mapRegion.center.longitude = loc.coordinate.longitude
mapRegion.center.latitude = loc.coordinate.latitude
mapRegion.span.latitudeDelta = 0.03 // I choose 0.03 by trying
mapRegion.span.longitudeDelta = 0.03
mapView.setRegion(mapRegion, animated: true)
This works good when the place marks are cities as it shows a larger area at a reasonable zoom level. But when I want to show a specific street (which is the CLPlacemark
s Location) in the city it is to far away.
Now I'm looking for a way to calculate the right span according to the "detail" of your CLPlacemark
(Note that you don't know the type of the CLPlacemark
upfront)
Is there a way to do this?