|
@@ -1,24 +1,57 @@
|
|
<template>
|
|
<template>
|
|
- <div id="mapValue"></div>
|
|
|
|
|
|
+ <div>
|
|
|
|
+ <div id="mapValue" ></div>
|
|
|
|
+ <!--控制条-->
|
|
|
|
+ <div class="map-control" v-if="isStart">
|
|
|
|
+ <div class="clickIco" @click="startAnimation()">
|
|
|
|
+ <i class="zoniot_font" :class="isSta?'zoniot-icon-kaishi':'zoniot-icon-tingzhi'"></i>
|
|
|
|
+ </div>
|
|
|
|
+ <el-slider
|
|
|
|
+ class="slider"
|
|
|
|
+ v-model="sliderVal"
|
|
|
|
+ :format-tooltip="hideFormat"
|
|
|
|
+ :step="0.0001"
|
|
|
|
+ ></el-slider>
|
|
|
|
+ <el-select v-model="speed">
|
|
|
|
+ <el-option :value="1000" label="1倍速"></el-option>
|
|
|
|
+ <el-option :value="1500" label="1.5倍速"></el-option>
|
|
|
|
+ <el-option :value="2000" label="2倍速"></el-option>
|
|
|
|
+ <el-option :value="3000" label="3倍速"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
export default {
|
|
export default {
|
|
- props: ['point'],
|
|
|
|
|
|
+ props: ['point','isStart'],
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
map: '',
|
|
map: '',
|
|
marker: '',
|
|
marker: '',
|
|
- icon: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png'
|
|
|
|
|
|
+ icon: 'https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png',
|
|
|
|
+ markerArr: [],
|
|
|
|
+ lineArr: [],
|
|
|
|
+ marker2: '',
|
|
|
|
+ speed: 1000,
|
|
|
|
+ sliderVal: 0,
|
|
|
|
+ isSta: true
|
|
};
|
|
};
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
point(e) {
|
|
point(e) {
|
|
- this.point.map((item) => {
|
|
|
|
|
|
+ this.point.map((item, index) => {
|
|
|
|
+ let tag = false;
|
|
|
|
+ if (index == this.point.length - 1) {
|
|
|
|
+ tag = true;
|
|
|
|
+ }
|
|
if (!!this.map) {
|
|
if (!!this.map) {
|
|
- this.addIcon(item);
|
|
|
|
|
|
+ this.addIcon(item, tag);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ },
|
|
|
|
+ speed(e) {
|
|
|
|
+ this.startAnimation(e);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -28,16 +61,69 @@ export default {
|
|
zoom: 11 //初始化地图层级
|
|
zoom: 11 //初始化地图层级
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- addIcon(e) {
|
|
|
|
|
|
+ addIcon(e, is) {
|
|
let _this = this;
|
|
let _this = this;
|
|
- _this.marker = new AMap.Marker({
|
|
|
|
- icon: _this.icon,
|
|
|
|
- position: [e.longitude, e.latitude]
|
|
|
|
- // map: _this.map
|
|
|
|
|
|
+ let lineArr = [e.longitude, e.latitude];
|
|
|
|
+ this.marker = new AMap.Marker({
|
|
|
|
+ icon: this.icon,
|
|
|
|
+ position: lineArr
|
|
});
|
|
});
|
|
- // this.marker.setMap(this.map);
|
|
|
|
this.map.add(this.marker);
|
|
this.map.add(this.marker);
|
|
|
|
+ this.markerArr.push(this.marker);
|
|
|
|
+ this.lineArr.push(lineArr);
|
|
this.map.setFitView();
|
|
this.map.setFitView();
|
|
|
|
+ if (is) {
|
|
|
|
+ this.initLineArr();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ initLineArr() {
|
|
|
|
+ let _this = this;
|
|
|
|
+ this.marker2 = new AMap.Marker({
|
|
|
|
+ map: _this.map,
|
|
|
|
+ position: _this.lineArr[0],
|
|
|
|
+ icon: 'https://webapi.amap.com/images/car.png',
|
|
|
|
+ offset: new AMap.Pixel(-26, -13),
|
|
|
|
+ autoRotation: true,
|
|
|
|
+ angle: -90
|
|
|
|
+ });
|
|
|
|
+ // 绘制轨迹
|
|
|
|
+ let polyline = new AMap.Polyline({
|
|
|
|
+ map: this.map,
|
|
|
|
+ path: _this.lineArr,
|
|
|
|
+ showDir: true,
|
|
|
|
+ strokeColor: '#28F', //线颜色
|
|
|
|
+ // strokeOpacity: 1, //线透明度
|
|
|
|
+ strokeWeight: 6 //线宽
|
|
|
|
+ // strokeStyle: "solid" //线样式
|
|
|
|
+ });
|
|
|
|
+ let passedPolyline = new AMap.Polyline({
|
|
|
|
+ map: _this.map,
|
|
|
|
+ // path: lineArr,
|
|
|
|
+ strokeColor: '#AF5', //线颜色
|
|
|
|
+ // strokeOpacity: 1, //线透明度
|
|
|
|
+ strokeWeight: 6 //线宽
|
|
|
|
+ // strokeStyle: "solid" //线样式
|
|
|
|
+ });
|
|
|
|
+ this.marker2.on('moving', e => {
|
|
|
|
+ passedPolyline.setPath(e.passedPath);
|
|
|
|
+ });
|
|
|
|
+ this.marker2.on('moveend', e => {
|
|
|
|
+ this.isSta = true;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ startAnimation(time) {
|
|
|
|
+ let _this = this;
|
|
|
|
+ this.isSta = false;
|
|
|
|
+ this.marker2.moveAlong(
|
|
|
|
+ this.lineArr,
|
|
|
|
+ time | 1000,
|
|
|
|
+ e => {
|
|
|
|
+ this.sliderVal = e * 100;
|
|
|
|
+ return e;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ false
|
|
|
|
+ );
|
|
}
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
@@ -50,7 +136,7 @@ export default {
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|
|
/* --------------------------------高德地图样式----------------------------- */
|
|
/* --------------------------------高德地图样式----------------------------- */
|
|
#mapValue {
|
|
#mapValue {
|
|
- margin-top: 20px;
|
|
|
|
|
|
+ // margin-top: 20px;
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 300px;
|
|
height: 300px;
|
|
}
|
|
}
|
|
@@ -69,4 +155,16 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+.map-control {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-between;
|
|
|
|
+ margin-top: 20px;
|
|
|
|
+ .clickIco i {
|
|
|
|
+ font-size: 30px;
|
|
|
|
+ line-height: 31px;
|
|
|
|
+ }
|
|
|
|
+ .slider {
|
|
|
|
+ width: calc(100% - 270px);
|
|
|
|
+ }
|
|
|
|
+}
|
|
</style>
|
|
</style>
|