如何缩放到 Swift 3 (Xcode 8) 中的特定坐标?
How can I zoom to certain coordinates in Swift 3 (Xcode 8)?
我正在尝试使用坐标缩放到特定位置。
我怎样才能做到这一点?
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
}
我正在尝试使用坐标缩放到特定位置。 我怎样才能做到这一点?
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
}