2017-11-10 5 views

答えて

0
import UIKit 
import MapKit 

class HomeViewController: UIViewController, MKMapViewDelegate { 

@IBOutlet weak var mapView: MKMapView! 

override func viewDidLoad() { 
    super.viewDidLoad() 
    mapView.showsUserLocation = true 


    if let userLocation = mapView.userLocation.location { 
     //let frontedUserLocation = CLLocationCoordinate2DMake(37.7857, -122.4021) 
     mapView.centerCoordinate = userLocation.coordinate 
     //mapView.centerCoordinate = frontedUserLocation 
     //let region = MKCoordinateRegionMakeWithDistance(frontedUserLocation, 1855, 1855) 
     let region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 9484.1, 9484.1) 
     mapView.setRegion(region, animated: true) 
    } 
    mapView.delegate = self 
}