Я использую MapBox и инстанцирование так:MapBox расположения анимировать пользователь быть более гладкой
import MapboxGL
class RideViewController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate, MGLMapViewDelegate{
@IBOutlet weak var mapViewWrapper: UIView!
var mapView: MGLMapView!
override func viewDidLoad(){
// Location manager
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
locationManager.activityType = .Fitness
// Mapbox
mapView = MGLMapView(frame: mapViewWrapper.bounds, styleURL: NSURL(string: Mapbox.getTheme()))
mapView.autoresizingMask = .FlexibleWidth | .FlexibleHeight
mapView.userTrackingMode = .Follow
mapView.showsUserLocation = true
mapView.scrollEnabled = false
mapView.rotateEnabled = false
mapView.logoView.hidden = true
mapView.attributionButton.hidden = true
// set the map's center coordinate
mapView.setCenterCoordinate(appleMap.userLocation.coordinate,
zoomLevel: 12, animated: true)
mapViewWrapper.addSubview(mapView)
}
func locationManager(manager:CLLocationManager, didUpdateLocations locations:[AnyObject]) {
myLocations.append(locations[0] as! CLLocation)
mapView.setCenterCoordinate(appleMap.userLocation.coordinate, zoomLevel: 16, animated: true)
}
}
Как вы можете видеть, у меня есть animated: true
, но это очень нервные, любые идеи, что я делаю неправильно?
Я попытался 'userTrackingMode = .Follow' (как показано выше), но если я не делаю locationManager это не добавляет пользовательский маркер. Не уверен, что я делаю неправильно. Что-то не хватает? – denislexic