放大用户位置-迅速 [英] Zoom in on User Location- Swift

查看:88
本文介绍了放大用户位置-迅速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何从viewDidLoad中获取地图以放大用户位置.我尝试设置一个区域,但没有成功.这是我的代码,有什么提示吗?

I can't figure out how to get the map to zoom in on the user location from viewDidLoad. I tried setting a region, and that didn't work. This is the code I have, any tips?

@IBOutlet弱var mapView:MKMapView! var MapViewLocationManager:CLLocationManager! = CLLocationManager() var currentLocation:PFGeoPoint! = PFGeoPoint()

@IBOutlet weak var mapView: MKMapView! var 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中找到答案,或者它确实有效.谢谢!!

I have looked up the answers for this question but haven't found the answer in Swift or that actually works. Thanks!!

推荐答案

我会尝试这样的事情:

    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)

我看到您说您尝试设置区域.也许尝试用这种方式.

I saw you said you tried setting a region. Maybe try doing it this way.

这篇关于放大用户位置-迅速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆