diff --git a/src/api/table.js b/src/api/table.js index 2ef3668..775285f 100644 --- a/src/api/table.js +++ b/src/api/table.js @@ -43,3 +43,4 @@ export function insertCar(carInsert) { data:carInsert }) } + diff --git a/src/views/vehicle/car.vue b/src/views/vehicle/car.vue index da67a92..d81718f 100644 --- a/src/views/vehicle/car.vue +++ b/src/views/vehicle/car.vue @@ -199,7 +199,7 @@ export default { equipmentId: String, }, beforeDestroy() { - this.map && this.map.destroy();//离开页面,销毁掉 + // this.map && this.map.destroy();//离开页面,销毁掉 }, data() { return { @@ -265,8 +265,7 @@ export default { }; }, mounted() { - this.initMap() - this.startAnimation() + }, created() { this.getList() @@ -289,6 +288,8 @@ export default { isShowAll(){ this.isShow = true this.isList = false + // this.map.destroy();//离开页面,销毁掉 + location.reload() }, insertCar(){ insertCar(this.carInsert).then(res=>{ @@ -316,6 +317,8 @@ export default { realTimeTrajectory(){ this.isShow = false this.isList = true + this.initMap() + this.startAnimation() }, /*刷新*/ refreshTable(){ @@ -379,14 +382,14 @@ export default { "AMap.DragRoute", "AMap.MoveAnimation"], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 }).then((AMap) => { -// 获取到作为地图容器的DOM元素,创建地图实例 + // 获取到作为地图容器的DOM元素,创建地图实例 this.map = new AMap.Map("container", { //设置地图容器id resizeEnable: true, viewMode: "3D", // 使用3D视图 zoomEnable: true, // 地图是否可缩放,默认值为true dragEnable: true, // 地图是否可通过鼠标拖拽平移,默认为true doubleClickZoom: true, // 地图是否可通过双击鼠标放大地图,默认为true - zoom: 13, //初始化地图级别 + zoom: 17, //初始化地图级别 center: this.lineArr[0], // 初始化中心点坐标 北京 // mapStyle: "amap://styles/darkblue", // 设置颜色底层 }) @@ -418,13 +421,14 @@ export default { // 监听marker移动 this.marker.on('moving', (e) => { - console.log('marker动了', e) this.passedPolyline.setPath(e.passedPath); // 设置路径样式 this.map.setCenter(e.target.getPosition(), true) // 设置地图中心点 }); this.map.setFitView(); // 根据覆盖物自适应展示地图 + }).catch(e => { + console.log(e) }) }, startAnimation () {