1 import UIKit
2 import MapKit
3
4 class ViewController:UIViewController {
5
6 override func viewDidLoad() {
7 super.viewDidLoad()
8 // Do any additional setup after loading the view,
typically from a nib.
9
10 let mapView = MKMapView(frame:self.view.bounds)
11 mapView.mapType = MKMapType.standard
12 mapView.showsScale = true
13 mapView.showsTraffic = true
14 mapView.showsPointsOfInterest = true
15
16 let coordinate2D = CLLocationCoordinate2D(latitude:
39.915352, longitude:116.397105)
17 let zoomLevel = 0.02
18 let region = MKCoordinateRegionMake(coordinate2D,
MKCoordinateSpanMake(zoomLevel, zoomLevel))
19 mapView.setRegion(region, animated:true)
20
21 self.view.addSubview(mapView)
22 }
23 }