轨迹地图

master
张小东 2023-11-25 12:50:27 +08:00
parent 3ed8ac5b62
commit 4a2f8d6836
3 changed files with 208 additions and 1 deletions

View File

@ -36,6 +36,7 @@
"url": "https://gitee.com/y_project/MuYu-Cloud.git"
},
"dependencies": {
"@amap/amap-jsapi-loader": "^1.0.1",
"@riophae/vue-treeselect": "0.4.0",
"axios": "0.24.0",
"clipboard": "2.0.8",

View File

@ -160,7 +160,18 @@ export const dynamicRoutes = [
meta: {title: '修改生成配置', activeMenu: '/tool/gen'}
}
]
},
{
path: '/system/map',
children: [
{
path: 'index',
name: '实时轨迹',
component: () => import('@/views/system/map/map.vue'),
meta: { title: '实时轨迹', icon: 'form' }
}
]
},
]
// 防止连续点击多次路由报错

View File

@ -0,0 +1,195 @@
<template>
<div>
<el-row>
<div id="container"></div>
<div class="input-card" v-show="true">
<div class="input-item">
<el-button type="primary" size="small" style="width: 90px" @click="startAnimation"></el-button>
<el-button type="primary" size="small" style="width: 90px" @click="pauseAnimation"></el-button>
<el-button type="primary" size="small" style="width: 90px" @click="resumeAnimation"></el-button>
<el-button type="primary" size="small" style="width: 90px" @click="stopAnimation"></el-button>
</div>
</div>
</el-row>
</div>
</template>
<script>
// js js json
// import from ' ';
//6911d4b3d9f7745cfed4ab0c87ad9b3f
//Key:965af9776cc04fc39f19b9ced7423ca0
import AMapLoader from "@amap/amap-jsapi-loader";
//
window._AMapSecurityConfig = {
securityJsCode: '6911d4b3d9f7745cfed4ab0c87ad9b3f',
}
export default {
name: 'TrackContainer',
//import 使
components: {},
props: {
visible: Boolean,
},
data() {
//
return {
AMap: null,
// map 使 this.map
map: null,
mouseTool: null,
marker: null,
lineArr: [],
};
},
// data
computed: {},
// data
watch: {
},
//
methods: {
pauseAnimation () {
this.marker.pauseMove();
},
resumeAnimation () {
this.marker.resumeMove();
},
stopAnimation () {
this.marker.stopMove();
},
startAnimation () {
this.marker.moveAlong(this.lineArr, {
//
duration: 500,//
// JSAPI2.0 moveAlong
autoRotation: true,
});
},
initMap() {
AMapLoader.load({
key: "965af9776cc04fc39f19b9ced7423ca0", // WebKey load
version: "2.0", // JSAPI 1.4.15
"plugins": [
"AMap.Scale",
"AMap.HawkEye",
"AMap.ToolBar",
"AMap.AutoComplete",
"AMap.PlaceSearch",
"AMap.ControlBar",
"AMap.MouseTool",
"AMap.DragRoute",
"AMap.MoveAnimation"], // 使'AMap.Scale'
}).then((AMap) => {
this.AMap=AMap
this.marker=null;
this.lineArr = [[116.478935,39.997761],[116.478939,39.997825],[116.478912,39.998549],[116.478912,39.998549],[116.478998,39.998555],[116.478998,39.998555],[116.479282,39.99856],[116.479658,39.998528],[116.480151,39.998453],[116.480784,39.998302],[116.480784,39.998302],[116.481149,39.998184],[116.481573,39.997997],[116.481863,39.997846],[116.482072,39.997718],[116.482362,39.997718],[116.483633,39.998935],[116.48367,39.998968],[116.484648,39.999861]];
this.map = new AMap.Map("container", { //id
viewMode: "2D", // 3D
zoom: 13, //
center: [116.478935,39.997761], // 104.065735, 30.659462
resizeEnable: true
});
this.marker = new AMap.Marker({
map: this.map,
position: [116.478935,39.997761],
icon: "https://a.amap.com/jsapi_demos/static/demo-center-v2/car.png",
offset: new AMap.Pixel(-13, -26),
});
//
var polyline = new AMap.Polyline({
map: this.map,
path: this.lineArr,
showDir:true,
strokeColor: "#28F", //线
// strokeOpacity: 1, //线
strokeWeight: 6, //线
// strokeStyle: "solid" //线
});
var passedPolyline = new AMap.Polyline({
map: this.map,
strokeColor: "#AF5", //线
strokeWeight: 6, //线
});
this.marker.on('moving', function (e) {
passedPolyline.setPath(e.passedPath);
this.map.setCenter(e.target.getPosition(),true)
}.bind(this));
this.map.setFitView();
}).catch(e => {
console.log(e);
})
},
},
// - 访 this
created() {
},
// - 访 DOM
mounted() {
this.initMap();
},
// -
beforeCreate() {
},
// -
beforeMount() {
},
// -
beforeUpdate() {
},
// -
updated() {
},
// -
beforeDestroy() {
},
// -
destroyed() {
},
// keep-alive
activated() {
},
}
</script>
<style scoped>
#container {
padding: 0px;
margin: 0px;
width: 100%;
height: 800px;
}
.input-item {
height: 2.2rem;
}
.input-card {
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border-radius: .25rem;
width: 10rem;
border-width: 0;
border-radius: 0.4rem;
box-shadow: 0 2px 6px 0 rgba(114, 124, 245, .5);
position: fixed;
bottom: 12rem;
right: 2rem;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
padding: 0.75rem 1.25rem;
}
</style>