Created
November 7, 2017 16:06
-
-
Save rodydavis/271ebe520c906d8386d7fe4a2d94d774 to your computer and use it in GitHub Desktop.
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
func map(address: String, title: String, name: String) { | |
let location = address | |
let geocoder = CLGeocoder() | |
geocoder.geocodeAddressString(location) { [weak self] placemarks, error in | |
if let placemark = placemarks?.first, let location = placemark.location { | |
let mark = MKPlacemark(placemark: placemark) | |
let coordinates:CLLocationCoordinate2D = placemark.location!.coordinate | |
if var region = self?.mapView.region { | |
region.center = location.coordinate | |
region.span.longitudeDelta /= 2500.0 | |
region.span.latitudeDelta /= 2500.0 | |
self?.mapView.setRegion(region, animated: true) | |
self?.mapView.addAnnotation(mark) | |
} | |
print("Lat: \(coordinates.latitude) -- Long: \(coordinates.longitude)") | |
self?.lat = coordinates.latitude | |
self?.lon = coordinates.longitude | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment