2
Guys, I’d like to know how I can get my map to show the place that was searched and center the view at this point. I was able to do with the current location as follows:
self.mapDisplay.setUserTrackingMode(MKUserTrackingMode.Follow, animated: true) //Linha de seguir o mapa
However I need with the result of the searched address, what I should use?
Update 1:
First I created a Geocoder:
var geocoder = CLGeocoder()
Then I used the method of fetching an address string and putting it into the Placemark variable. And using the properties available in this variable I used Placemark.location.coordinate.latitude and Placemark.location.coordinate.longitute:
geocoder.geocodeAddressString(address,{(placemarks: [AnyObject]!, error: NSError!) -> Void in
if let placemark = placemarks?[0] as? CLPlacemark {
let location = CLLocationCoordinate2D(latitude: placemark.location.coordinate.latitude, longitude: placemark.location.coordinate.longitude)
self.mapView.region = MKCoordinateRegionMakeWithDistance(location, 350, 350)
self.mapView.centerCoordinate = location
}
You already have this method of finding coordinates from the address or is it from there that you need?
– Paulo Rodrigues
It is from there that I need, I do not possess the method.
– Skalwalker