Skip to content

Instantly share code, notes, and snippets.

@mchirico
Created November 2, 2015 22:28
Show Gist options
  • Save mchirico/fac2650e4e312898b2ce to your computer and use it in GitHub Desktop.
Save mchirico/fac2650e4e312898b2ce to your computer and use it in GitHub Desktop.
Quick and dirty...creating a map in swift, using MKMapView
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)
}
}
@mchirico
Copy link
Author

mchirico commented Nov 2, 2015

Here's what it looks like...
screenshot 2015-11-02 17 29 18

Remember, you also have enable maps in capabilities.

screenshot 2015-11-02 17 31 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment