Last active
August 29, 2015 14:03
-
-
Save genedelisa/354e171c72377f77280c to your computer and use it in GitHub Desktop.
Set map location from string
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
self.geocoder.geocodeAddressString("Haddonfield, NJ", | |
completionHandler: {(placemarks, error:NSError!) in | |
if error? { | |
println("Error \(error!.localizedDescription)") | |
if error!.code == 8 { | |
println("not found") | |
} | |
return | |
} | |
let pma:Array<CLPlacemark> = placemarks as Array<CLPlacemark> | |
var placemark = pma[pma.endIndex - 1] | |
// in degrees | |
var spanX = 0.5 | |
var spanY = 0.5 | |
var span:MKCoordinateSpan = MKCoordinateSpanMake(spanX, spanY) | |
var region:MKCoordinateRegion = MKCoordinateRegion(center:placemark.location.coordinate, | |
span:span) | |
self.mapView.setRegion(region, animated:true) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment