2016-09-09 38 views
0

需要什么样的代码才能使我的酒吧按钮定位并缩放到用户的位置,例如在Google地图中?我试过以下内容:导航按钮用户位置

if Navigationbutton != nil { 
    Navigationbutton.target = MKMapView() 
    Navigationbutton.action = CLLocationCoordinate2D (latitude: location!.coordinate.latitude, longitude: location.coordinate.longitude) 

回答

0

这就是您寻找的是:

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { 
    // Get location 
    let location:CLLocationCoordinate2D = manager.location!.coordinate 

    // Center map 
    let span = MKCoordinateSpanMake(0.014, 0.014) 
    let region = MKCoordinateRegion(center: location, span: span) 
    mapView.setRegion(region, animated: true) 
}