標準地図表示
MapKit framework を追加
import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate {
@IBOutlet weak var mkMap: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Delegate をセット
self.mkMap?.delegate = self
// 緯度・軽度を設定 大阪難波
var location:CLLocationCoordinate2D
= CLLocationCoordinate2DMake(34.666316,135.500277)
mkMap?.setCenterCoordinate(location,animated:true)
// 縮尺を設定
var region:MKCoordinateRegion = self.mkMap!.region
region.center = location
region.span.latitudeDelta = 0.02
region.span.longitudeDelta = 0.02
self.mkMap!.setRegion(region,animated:true)
// 表示タイプを標準写真に設定
/*
* MKMapType.Standard 標準写真
* MKMapType.Satellite 航空写真
* MKMapType.Hybrid ハイブリット
*/
self.mkMap!.mapType = MKMapType.Standard
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
GitHub MapViewSwift01
▫️参考ページ
コメントをお書きください
Mui Yarber (月曜日, 23 1月 2017 06:11)
What's Happening i'm new to this, I stumbled upon this I've discovered It absolutely helpful and it has helped me out loads. I'm hoping to give a contribution & assist other customers like its aided me. Great job.
Delinda Boren (月曜日, 23 1月 2017 06:45)
Having read this I believed it was rather enlightening. I appreciate you spending some time and effort to put this content together. I once again find myself spending way too much time both reading and commenting. But so what, it was still worthwhile!