Friday, August 7, 2015

Swift Tutorial for iOS: Part 4 - MapKit App Displaying World's Tallest Church | AppShocker

Swift Tutorial for iOS: Part 4 - MapKit App Displaying World's Tallest Church | AppShocker


done.
simple but good to know how to make a pin with it's annotation..


import UIKit
import MapKit

class ViewController: UIViewController, MKMapViewDelegate {
    @IBOutlet weak var theMapview: MKMapView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        var latitude:CLLocationDegrees = 48.399193
        var longitude:CLLocationDegrees = 9/993341
        
        //zoom
        var latDelta:CLLocationDegrees = 0.01
        var longDelta:CLLocationDegrees = 0.01
        
        var theSpan:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)
        
        var churchLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
        
        var theRegion: MKCoordinateRegion = MKCoordinateRegionMake(churchLocation, theSpan)
        
        self.theMapview.setRegion(theRegion, animated: true)
        
        var theUlmMinsterAnnotation = MKPointAnnotation()
        theUlmMinsterAnnotation.coordinate = churchLocation
        
        theUlmMinsterAnnotation.title = "ulm Minster"
        theUlmMinsterAnnotation.subtitle = "A famous church in Germany"
        
        self.theMapview.addAnnotation(theUlmMinsterAnnotation)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }



}

https://www.youtube.com/watch?v=uB100xVS_Yc

No comments:

Post a Comment