読者です 読者をやめる 読者になる 読者になる

swift: iOSのマップの縮尺

CLLocationDistance がキモっぽい

class MapViewController: UIViewController, MKMapViewDelegate {
    var mapView: MKMapView!

    override func viewDidLoad() {
        super.viewDidLoad()

        mapView = MKMapView()
        mapView.frame = self.view.bounds
        mapView.delegate = self
        mapView.rotateEnabled = false
        mapView.showsUserLocation = true
        self.view.addSubview(mapView)

        let lat: CLLocationDegrees = 35.6827593
        let lon: CLLocationDegrees = 139.7630758

        let latDist: CLLocationDistance = 100000
        let lonDist: CLLocationDistance = 100000
        let coordinate: CLLocationCoordinate2D =
            CLLocationCoordinate2DMake(lat, lon)

        let region: MKCoordinateRegion =
        MKCoordinateRegionMakeWithDistance(coordinate, latDist, lonDist)

        mapView.setRegion(region, animated: true)
    }

    /**
     * Regionが変更された時に呼び出されるメソッド
     */
    func mapView (mapView: MKMapView!, regionDidChangeAnimated animated: Bool) {
        print("regionDidChangeAnimated")
    }
}