Ios 用户位置查找器

Ios 用户位置查找器,ios,swift,uibutton,Ios,Swift,Uibutton,我有一个按钮,当它被按下时,它会进入用户的位置。我不知道该放什么,这样我就可以放大用户的位置 我在按钮中输入了以下代码 @IBAction func Refreshbutton(sender: AnyObject) { Mapview.setCenterCoordinate(Mapview.userLocation.coordinate, animated: true) } 我在Swift中就是这样做的: @IBAction func CenterMapToUserLoca

我有一个按钮,当它被按下时,它会进入用户的位置。我不知道该放什么,这样我就可以放大用户的位置

我在按钮中输入了以下代码

@IBAction func Refreshbutton(sender: AnyObject) {   
    Mapview.setCenterCoordinate(Mapview.userLocation.coordinate, animated: true)
}

我在Swift中就是这样做的:

   @IBAction func CenterMapToUserLocation(sender: AnyObject) {
        let latitude = locationManager.location?.coordinate.latitude
        let longitude = locationManager.location?.coordinate.longitude
        let span = MKCoordinateSpanMake(0.02, 0.02)
        let region = MKCoordinateRegion(center:CLLocationCoordinate2D(latitude: latitude!, longitude: longitude!),span: span)
        tripMapView.setRegion(region, animated: true)
    }

你救了我一天,谢谢!另外,你知道如何在应用程序启动时让地图自动缩放用户位置吗?我在info.plist中输入了NSstring,并输入了以下代码:func locationManager(manager:CLLocationManager,didUpdateLocations locations:[CLLocation],[AnyObject]){let latitude=Locationmanager.location?.coordinate.latitude let longitude=Locationmanager.location?.coordinate.longitude let span=MKCoordinateSpanMake(0.05,0.05)let region=MKCoordinateRegion(中心:CLLocationCoordinate2DMake(纬度,经度!),span:span)self.Mapview.setRegion(区域,动画:true)self.Locationmanager.StopUpdatengLocation()