Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let locations = [
- ["name" : "Apple Inc.",
- "latitude" : 37.33187,
- "longitude" : -122.02951,
- "mediaURL" : "http://www.apple.com"],
- ["name" : "BJ's Restaurant & Brewhouse",
- "latitude" : 37.33131,
- "longitude" : -122.03175,
- "mediaURL" : "http://www.bjsrestaurants.com"]
- ]
- var annotations = [MGLPointAnnotation]()
- for dictionary in locations {
- let latitude = CLLocationDegrees(dictionary["latitude"] as! Double)
- let longitude = CLLocationDegrees(dictionary["longitude"] as! Double)
- let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
- let name = dictionary["name"] as! String
- let discription = dictionary["mediaURL"] as! String
- let annotation = MGLPointAnnotation()
- annotation.coordinate = coordinate
- annotation.title = "(name)"
- annotation.subtitle = "(discription)"
- annotations.append(annotation)
- }
- mapView.addAnnotation(annotations as! MGLAnnotation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement