2016-10-30 1 views
0

Googleのオンラインドキュメントのいくつかをフォローして、GoogleマップAPIを設定しました。 1つの問題があります。ユーザーの場所を取得すると、Googleマップの表示はユーザーの場所に表示されず/スナップ/アニメーションされません。私はユーザーの場所を正常に取得することができます。googlemapsをユーザーのアクティブな場所に設定することができません。

現在地マネージャ:

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){ 
    let newUserLocation: CLLocation = locations[0] 
    let latitude: CLLocationDegrees = newUserLocation.coordinate.latitude 
    let longitude: CLLocationDegrees = newUserLocation.coordinate.longitude 
    userLocation = PFGeoPoint(latitude:latitude, longitude:longitude) 


    let Camera = GMSCameraPosition.camera(withLatitude: userLocation.latitude, longitude: userLocation.longitude, zoom: 15) 
    self.MapView.isMyLocationEnabled = true 
    self.MapView = GMSMapView.map(withFrame: CGRect.zero , camera: Camera) 

} 

私のviewDidLoad:

override func viewDidLoad() { 
    super.viewDidLoad() 

    locationManager.delegate = self 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest 
    locationManager.requestAlwaysAuthorization() 
    locationManager.startUpdatingLocation() 


} 

答えて

0

私はこの問題を回避するには、これは有効であるが、それは私のiOSシミュレータで私のために動作するかどうかわからないを発見しました。 Camera変数を作成した後に、次の2行のコードを追加しました。

MapView.animate(toLocation: newUserLocation.coordinate) 
    MapView.animate(toZoom: 15) 
関連する問題