Created
November 2, 2015 22:28
-
-
Save mchirico/fac2650e4e312898b2ce to your computer and use it in GitHub Desktop.
Quick and dirty...creating a map in swift, using MKMapView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import MapKit | |
class VCMap: UIViewController { | |
@IBOutlet weak var map: MKMapView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
// 40.0697037,lon: -75.1253492 | |
let location = CLLocationCoordinate2D( | |
latitude: 40.0697037, | |
longitude: -75.1253492 | |
) | |
let span = MKCoordinateSpanMake(0.5, 0.5) | |
let region = MKCoordinateRegion(center: location, span: span) | |
map.setRegion(region, animated: true) | |
let annotation = MKPointAnnotation() | |
annotation.coordinate = location | |
annotation.title = "Main" | |
annotation.subtitle = "Sub" | |
map.addAnnotation(annotation) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's what it looks like...
Remember, you also have enable maps in capabilities.