2017-07-24 97 views
0

我正在使用iOS中的Google地图。我想动画我的相机,以显示所有需要的经纬度。我将这些位置存储在数组中(作为CLLocationCoordinate2D实例)并使用GMSCoordinateBounds类来添加这些位置。这是我的代码:(iOS Swift)谷歌地图animateWithCameraUpdate无法正常工作

 let bounds = GMSCoordinateBounds() 
     bounds.includingCoordinate(firstLocation) 
     bounds.includingCoordinate(lastLocation) 
     let camUpdate = GMSCameraUpdate.fit(bounds, withPadding: 60) 

     mMapView.camera = GMSCameraPosition.camera(withLatitude: firstLocation.latitude, longitude: firstLocation.longitude, zoom: 18) 

     mMapView.animate(with: camUpdate) 

firstLocation和lastLocation具有正确的值,但相机不具有动画效果。我错过了什么吗?

回答

1

非常愚蠢的错误。包括坐标函数返回GMSCoordinateBounds对象。我不得不重新设置它自己的工作是这样的:

bounds = bounds.includingCoordinate(firstLocation) 

bounds = bounds.includingCoordinate(lastLocation) 

如果我像上面设置,它工作正常。