我想在GoogleMap
上绘制带有动画的折线,就像Uber
一样。目前,我可以在绘制时进行动画处理(不像Uber那样平滑),但是在移除时没有平滑性。
如何实现以下目标?
这是相关的代码。
@property(nonatomic, strong) GMSPath *poolRidePath;
@property (nonatomic,assign) int counter;
@property (nonatomic,strong) GMSMutablePath *trackPath;
@property (nonatomic,strong) GMSPolyline *yellowPolyLine;
@property (nonatomic,strong) NSMutableArray *arrayPolylineYellow;
@property (nonatomic,strong) GMSMapView *mapView;
.....
.....
.....
double time = 0.8/self.poolRidePath.count;
self.timerForPathProgressAnimation = [NSTimer scheduledTimerWithTimeInterval: time repeats:true block:^(NSTimer * _Nonnull timer) {
[self animateMapRouteLine: self.poolRidePath];
}];
.....
.....
.....
-(void)animateMapRouteLine:(GMSPath *)path {
if (self.counter < path.count) {
[self.trackPath addCoordinate:[path coordinateAtIndex: self.counter]];
self.yellowPolyLine = [GMSPolyline polylineWithPath: self.trackPath];
self.yellowPolyLine.strokeColor = [[CommonFunctions shareCommonMethods] colorFromHexString:@"#e6b800"];
self.yellowPolyLine.strokeWidth = 3;
self.yellowPolyLine.map = self.mapView;
[self.arrayPolylineYellow addObject: self.yellowPolyLine];
self.counter++;
} else {
self.counter = 0;
self.trackPath = [[GMSMutablePath alloc] init];
for (GMSPolyline *line in self.arrayPolylineYellow) {
line.map = nil;
}
}
}