Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. let locations = [
  2. ["name" : "Apple Inc.",
  3. "latitude" : 37.33187,
  4. "longitude" : -122.02951,
  5. "mediaURL" : "http://www.apple.com"],
  6. ["name" : "BJ's Restaurant & Brewhouse",
  7. "latitude" : 37.33131,
  8. "longitude" : -122.03175,
  9. "mediaURL" : "http://www.bjsrestaurants.com"]
  10. ]
  11.  
  12. var annotations = [MGLPointAnnotation]()
  13.  
  14. for dictionary in locations {
  15. let latitude = CLLocationDegrees(dictionary["latitude"] as! Double)
  16. let longitude = CLLocationDegrees(dictionary["longitude"] as! Double)
  17. let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
  18. let name = dictionary["name"] as! String
  19. let discription = dictionary["mediaURL"] as! String
  20. let annotation = MGLPointAnnotation()
  21. annotation.coordinate = coordinate
  22. annotation.title = "(name)"
  23. annotation.subtitle = "(discription)"
  24. annotations.append(annotation)
  25. }
  26.  
  27. mapView.addAnnotation(annotations as! MGLAnnotation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement