Thursday, September 11, 2014

MKPointAnnotation - Put a pin on a map

import MapKit
import CoreLocation

@IBOutlet weak var myMap: MKMapView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        var point = MKPointAnnotation()
        
        point.coordinate = CLLocationCoordinate2DMake(25.0305, 121.5360)
        point.title = "Taipei"
        point.subtitle = "Taiwan"
        myMap.addAnnotation(point)
        myMap.centerCoordinate = point.coordinate
        
        //Span of the map
        myMap.setRegion(MKCoordinateRegionMake(point.coordinate, MKCoordinateSpanMake(7,7)), animated: true)
    }

No comments:

Post a Comment