ios - 放大用户位置 - Swift

标签 ios swift mapkit

我不知道如何让 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/

相关文章:

ios - Swift 中的整数溢出

Iphone:将音频创建为文件时找不到音频 Assets 轨道,在应用程序中运行

ios - 在 ios 中为动画 uiimageview 添加 mask

Swift:对成员 'map' 的引用不明确

objective-c - 在 MapView 中显示 map 注释时遇到问题

iOS 13.2 MKTileOverlay 偶尔不会渲染

ios - Google Places API 违规

ios - 以编程方式对齐 iPhone 键盘顶部的工具栏

python - 将 .profo 文件的文件夹编译为多种语言

ios - Swift 4.2 如果让 Xcode 11.2 上的 CMTime 失败