代码之家  ›  专栏  ›  技术社区  ›  Shubham

如何在iOS中用GoogleMap动画绘制和删除多段线?

  •  0
  • Shubham  · 技术社区  · 6 年前

    我要在启用动画的情况下绘制和删除多段线 GoogleMap ,就像 Uber 做。目前,我可以在绘制时设置动画(不像Uber那样平滑),但删除时没有平滑度。

    我怎样才能做到以下几点?:

    1. 无论路径长度如何,绘制多段线的持续时间都应相同。
    2. 删除多段线时,我想使用淡出动画。

    这是相关代码。

    @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;
         } 
       }
    }
    
    0 回复  |  直到 6 年前