I have one class that has all the MapKit functions and another class where I call the MapKit. My goal is to give an address (String) and the map show a placemark with zoom to that location.
So far I managed to get the map working and the placemark is in the right street, but dont zoom to the placemark location.
Map is declared like:
@IBOutlet var mapPreview: MKMapView!
Here is the code of the placemark. How can I zoom to that placemark?
var address = restaurante.rua + " " + restaurante.numero + "," + restaurante.localidade + ", Portugal"
var geocoder = CLGeocoder()
geocoder.geocodeAddressString(address, completionHandler: {(placemarks: [AnyObject]!, error: NSError!) -> Void in
if let placemark = placemarks?[0] as? CLPlacemark {
self.mapPreview.addAnnotation(MKPlacemark(placemark: placemark))