【问题标题】:In Google Map SDK for IOS, how do I change the bearing of the map without animating it?在 Google Map SDK for IOS 中,如何在不设置动画的情况下更改地图的方位?
【发布时间】:2013-07-19 21:02:39
【问题描述】:

我可以改变我的地图的方位使用

[googleMapView animateToBearing:0.5];

但是如何做到这一点,使变化是瞬时的,没有动画?

【问题讨论】:

    标签: ios google-maps-sdk-ios


    【解决方案1】:

    抓取当前相机位置,改变方位,然后设置视图的相机位置:

    GMSCameraPosition *myCamera = googleMapView.camera;
    GMSCameraPosition *myNewCamera = [GMSCameraPosition cameraWithLatitude:myCamera.targetAsCoordinate.latitude longitude:myCamera.targetAsCoordinate.longitude zoom:myCamera.zoom bearing:0.5 viewingAngle:myCamera.viewingAngle];
    googleMapView.camera = myNewCamera;
    

    【讨论】:

      【解决方案2】:

      由于没有像 movetobearing 这样的直接选项,因此可以使用上述方法。另一种选择是使用[googleMapView animateToBearing:0.5];,然后将动画持续时间设置为非常低的值,例如 0.0001f,这会产生运动的视觉效果

      [CATransaction begin];
      [CATransaction setValue:[NSNumber numberWithFloat: 0.0001f] forKey:kCATransactionAnimationDuration];
      [mapView_ animateToBearing:0.5];
      [CATransaction commit];
      

      【讨论】:

        【解决方案3】:

        为了更流畅和过渡的更新,试试这个(视图是 GMSMapView)

        [self.view animateToCameraPosition:[GMSCameraPosition cameraWithLatitude:coordinate.latitude longitude:coordinate.longitude zoom:15 bearing:bearing viewingAngle:45]];
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-11-07
          • 2013-11-19
          • 2016-10-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多