在Google地图中移动相机

我正试图将相机在Google地图中移动到指定位置(经纬度)。

这是我的代码/函数,这个代码位于ViewController1(它包含mapView的视图):

func select_structure(lat: String, lon: String){ let camera = GMSCameraPosition.cameraWithLatitude(Double(lat)!, longitude: Double(lon)!, zoom: 6.0) mapView = GMSMapView.mapWithFrame(CGRect.zero, camera: camera) mapView.myLocationEnabled = true mapView.mapType = kGMSTypeSatellite mapView.camera = camera view = mapView populate_structures2() let newcamera = GMSCameraPosition.cameraWithLatitude(Double(lat)!, longitude: Double(lon)!, zoom: 17.0) self.mapView.animateToCameraPosition(newcamera) print(mapView) } 

当我在ViewController2中调用该代码时,第一次运行应用程序时,它不起作用。 当我使用这个函数时,什么都不会发生 但是我知道它正在被阅读。 而当我运行它的第二,第三等,它的作品!

只是一个简短的说明。 ViewController2是一个滑动菜单。 我从ViewController1调用这个函数:

 var ClassViewController = self.storyboard!.instantiateViewControllerWithIdentifier("ViewController") as! ViewController ClassViewController.select_structure(structures_lat[indexPath.item], lon: structures_lon[indexPath.item]) 

我在ViewController1的loadView中初始化mapView:

  override func loadView() { let camera = GMSCameraPosition.cameraWithLatitude(35.98917593, longitude: -95.94740106, zoom: 6.0) mapView = GMSMapView.mapWithFrame(CGRect.zero, camera: camera) mapView.myLocationEnabled = true mapView.mapType = kGMSTypeSatellite //mapView.delegate = self mapView.settings.allowScrollGesturesDuringRotateOrZoom = false view = mapView load_lines() load_structures() } 

任何想法?