我不知道如何让 map 从 viewDidLoad 放大用户位置。我尝试设置一个区域,但没有用。这是我的代码,有什么提示吗?
@IBOutlet 弱变量 mapView:MKMapView! 变种 MapViewLocationManager:CLLocationManager! = CLLocationManager() var currentLocation:PFGeoPoint! = PFGeoPoint()
override func viewDidLoad() {
super.viewDidLoad()
self.mapView.showsUserLocation = true
mapView.delegate = self
MapViewLocationManager.delegate = self
mapView.setUserTrackingMode(MKUserTrackingMode.Follow, animated: true)
}
我已经查找了这个问题的答案,但没有在 Swift 中找到答案,也没有找到真正有效的答案。谢谢!!
最佳答案
我会尝试这样的事情:
let latitude:CLLocationDegrees = //insert latitutde
let longitude:CLLocationDegrees = //insert longitude
let latDelta:CLLocationDegrees = 0.05
let lonDelta:CLLocationDegrees = 0.05
let span = MKCoordinateSpanMake(latDelta, lonDelta)
let location = CLLocationCoordinate2DMake(latitude, longitude)
let region = MKCoordinateRegionMake(location, span)
mapView.setRegion(region, animated: false)
我看到你说你试过设置一个区域。也许尝试这样做。
关于ios - 放大用户位置 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31040667/