Vue中使用高德地图历史轨迹回放-加速功能

在能让轨迹运动起来的前提下(基础功能),现在要加速运动和减速运动怎么做

直接看代码

    //加速   默认速度200,让他成倍数的加速自己设定一个固定的值就可以了
    startAdd() {
      if (this.markerSpeed < 1000) {
        this.markerSpeed = 200;
        this.speedCount++;
        this.speedCount = this.speedCount++;
        this.markerSpeed = this.markerSpeed * this.speedCount;
        this.marker.moveAlong(this.lineArr, this.markerSpeed);
      } else {
        this.speedCount = 5;
      }
    },
    //减速
    startRed() {
      if (this.markerSpeed > 200) {
        this.markerSpeed = 200;
        this.speedCount--;
        this.speedCount = this.speedCount--;
        console.log(this.speedCount);
        this.markerSpeed = this.markerSpeed * this.speedCount;
        this.marker.moveAlong(this.lineArr, this.markerSpeed);
      } else {
        this.marker.moveAlong(this.lineArr, 200);
        this.speedCount = 1;
      }
    },
    //开始运动      每次点击运动的时候让他回复到初始速度
    startAnimation() {
      this.speedCount = 1;
      this.markerSpeed = 200;
      this.marker.moveAlong(this.lineArr, this.markerSpeed);
    },

在这里插入000

Logo

前往低代码交流专区

更多推荐