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

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

发布了26 篇原创文章 · 获赞 55 · 访问量 5108

猜你喜欢

转载自blog.csdn.net/jinglianglove/article/details/102494591