如何在Objective c中沿坐标平滑移动GMSMarker

Sad*_*dia 11 google-maps objective-c

我正在使用谷歌地图sdk.我想在每5秒后更新引脚的gps坐标.目前我只是更新GMSMarker的位置属性.但它会产生跳跃效应.我想在地图上顺利移动标记.
这是我更新标记位置的代码

-(void)updateLocationoordinates(CLLocationCoordinate2D) coordinates
{ 
  if (marker == nil) {
      marker = [GMSMarker markerWithPosition:coordinates];
      marker.icon = [UIImage imageNamed:CAR_FOUND_IMAGE];
      marker.map = mapView_;
  } else
  marker.position = coordinates; 
}
Run Code Online (Sandbox Code Playgroud)

Bre*_*ett 35

将你的else块更改为更像这样的东西:

[CATransaction begin];
[CATransaction setAnimationDuration:2.0];
marker.position = coordindates;
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)

我们允许您使用Core Animation为Google地图设置动画.

有关工作示例,请参阅AnimatedCurrentLocationViewController.{c,m}SDK示例应用程序.

  • 好的 - 我骗了.它与海报提到的完全一样.我刚搞砸了我的考试.但是,我注意到编辑我的第一条评论为时已晚. (2认同)
  • 任何人都可以发送代码片段来设置谷歌地图折线的动画. (2认同)