Advertisement
Guest User

Search code

a guest
Feb 4th, 2017
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.92 KB | None | 0 0
  1.         let searchRadius: CLLocationDistance = 10000
  2.         let region = MKCoordinateRegionMakeWithDistance(location.coordinate, searchRadius * 2.0, searchRadius * 2.0)
  3.       
  4.         map.setRegion(region, animated: true)
  5.         let request = MKLocalSearchRequest()
  6.         request.naturalLanguageQuery = getRandomPlace()
  7.         request.region = map.region
  8.    
  9.         let search = MKLocalSearch(request: request)
  10.         search.start { response, error in
  11.             guard let response = response else {
  12.                 print("There was an error searching for: ")
  13.                 return
  14.             }
  15.        
  16.             for item in response.mapItems {
  17.                 self.dropPinZoomIn(item.placemark)
  18.             }
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement