Skip to content

Instantly share code, notes, and snippets.

@genedelisa
Last active August 29, 2015 14:03
Show Gist options
  • Save genedelisa/354e171c72377f77280c to your computer and use it in GitHub Desktop.
Save genedelisa/354e171c72377f77280c to your computer and use it in GitHub Desktop.
Set map location from string
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