Guest User

Untitled

a guest
Dec 15th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. var coordinate = [AnyObject]()
  2.  
  3. Alamofire.request(key).responseJSON { (response) in
  4. let data = response.result
  5.  
  6. if let json = data.value as? Dictionary<String,AnyObject>{
  7. if let results = json["results"]
  8. {
  9. if let geometry = results["geometry"] as? Dictionary<String,AnyObject>
  10. {
  11. if let location = geometry["location"]
  12. {
  13. self.coordinate = location as! [AnyObject]
  14. }
  15. }
  16. }
  17.  
  18. }
  19. }
  20.  
  21. {
  22. html_attributions: [ ],
  23. next_page_token: "CrQCIwEAAD1hVtsv2Rq1gXGAFL67ucrXNKqh-2Km4rUSgkPUYZA4apoWTxWmUgVKX9tYTyOkHRtfU6hJsu7QBq1fZNDWB-bAcryr8ADW4bBfszYCIDkg9F2JBrxn2iMFYspvx0aQSyblSD3EoYP2qmjD4itG_pCC67Eo_Pk1Xcsoxx4ZW5O9wvtrby7WNPOUGnIlSBOZ4R-5tjwkOEZCcroM3lBjF1fQbrZ7F-2_ymgf-h3C1sdW4iV4AG85rgIcWeeAW_uwamnyvChTSqSjf_q4IiqNoA9T-q4ZmZGXgkIOk2omzjqEm1Q563RRjGXSrRV8kTeF4t_S-Xeq4-05SRwe3Gx-3t9KBDXR9W9nRH8W08H08wrBYs0O239HUXLbgGLgmZr6h8n4YQbJETLCwI_QTCtOh3sSEMCf6iNSUBjd76aHUHN1b6YaFHTkB0-5Yh8szipA_BLiVYIE0ebm",
  24. results: [
  25. {
  26. geometry: {
  27. location: {
  28. lat: 51.51021369999999,
  29. lng: -0.1315736
  30. },
  31. viewport: {
  32. northeast: {
  33. lat: 51.51158128029149,
  34. lng: -0.130123169708498
  35. },
  36. southwest: {
  37. lat: 51.5088833197085,
  38. lng: -0.132821130291502
  39. }
  40. }
  41. },
  42. icon: "https://maps.gstatic.com/mapfiles/place_api/icons/lodging-
  43. 71.png",
  44. id: "b501c78eff5bb3e4b7f67dfe97727cec52a693c5",
  45. name: "Thistle Piccadilly Hotel",
  46. photos: [
  47. {
  48. height: 337,
  49. html_attributions: [
  50. "<a href="https://maps.google.com/maps/contrib/110195987647911662808/photos">Thistle Piccadilly Hotel</a>"
  51. ],
  52. photo_reference: "CmRaAAAA5ohge6XYb1kjWk5C_KJdzFRx3SBF9QjkZUgUQ36av_eSP-9sjkvwncvOk5gPvVeC_Tgj4lcYr0DDm-x3JxMvnLMykI7BzAJAdoYs2VKeGNPWxX0VKdH2m72PSUScH_f4EhBJqRr0iXUwsO-IQHO2TWPGGhS8mbZaVg5BaJLnGAtE6t-cyi2naA",
  53. width: 338
  54. }
  55. ],
  56. place_id: "ChIJZewrLtIEdkgRtl2nZKboAgk",
  57. plus_code: {
  58. compound_code: "GV69+39 St. James's, London, United Kingdom",
  59. global_code: "9C3XGV69+39"
  60. },
  61. rating: 4.4,
  62. reference: "ChIJZewrLtIEdkgRtl2nZKboAgk",
  63. scope: "GOOGLE",
  64. types: [
  65. "bar",
  66. "lodging",
  67. "restaurant",
  68. "point_of_interest",
  69. "food",
  70. "establishment"
  71. ],
  72. vicinity: "Coventry Street, London"
  73. }
  74. ],
  75. status: "OK"
  76. }
  77.  
  78. import CoreLocation
  79.  
  80. typealias JSONDictionary = [String:Any]
  81.  
  82. var coordinates = [CLLocationCoordinate2D]()
  83.  
  84. Alamofire.request(key).responseJSON { (response) in
  85. if let json = response.result.value as? JSONDictionary,
  86. let results = json["results"] as? [JSONDictionary] {
  87. for result in results {
  88. if let geometry = results["geometry"] as? JSONDictionary,
  89. let location = geometry["location"] as? JSONDictionary {
  90. coordinates.append(CLLocationCoordinate2D(latitude: location["lat"] as! Double, longitude: location["lng"] as! Double))
  91. }
  92. }
  93. }
  94. }
Add Comment
Please, Sign In to add comment