我可以在GoogleMaps上绘制GMSPolyline,其中包含这样的位置数组
GMSMutablePath *path = [GMSMutablePath path];
for (int i = 0; i <anotherArray.count; i++) {
NSString *string1 = [anotherArray2 objectAtIndex:i];
NSString *string2 = [anotherArray objectAtIndex:i];
[path addCoordinate:CLLocationCoordinate2DMake(string1.doubleValue,string2.doubleValue)];
}
GMSPolyline *rectangle = [GMSPolyline polylineWithPath:path];
rectangle.strokeColor = [UIColor blueColor];
rectangle.map = mapView_;
rectangle.strokeWidth = 2.0f;
但是我从后端服务器获取的位置。
所以我必须每10秒刷新一次,获取新位置并将其添加到现有路径。这些都很好。
但是当我向现有路径添加新位置时,移动速度非常快。
因为我在路径的起点有一个GMSMarker,看起来像是从一个地方跳到另一个地方。
那么我如何为GMSMarker制作动画,就像从一个地方慢慢移动到另一个地方一样?
答案 0 :(得分:0)
检查此tutorial。它说明了如何使用GMSPolyline
类在地图上绘制路线。从related SO thread:
将您的其他块更改为更像这样的内容:
[CATransaction begin]; [CATransaction setAnimationDuration:2.0]; marker.position = coordindates; [CATransaction commit];
我们允许您使用Core Animation 用于动画制作Google地图。
对于工作样品,请参阅 SDK示例中的
AnimatedCurrentLocationViewController.{c,m}
应用
同样基于此SO post,避免使用1px笔画宽度的线条。相反,使用4px笔画宽度。您还可以查看此GitHub sample。