| | |
| | | }; |
| | | }, |
| | | created() { |
| | | // 获取URL参数中的车牌号 |
| | | const vehicleNo = this.$route.query.vehicleNo; |
| | | if (vehicleNo) { |
| | | this.queryParams.vehicleNo = vehicleNo; |
| | | // 获取URL参数 |
| | | const query = this.$route.query; |
| | | if (query.vehicleNo) { |
| | | this.queryParams.vehicleNo = query.vehicleNo; |
| | | } |
| | | // 设置时间范围 |
| | | if (query.startTime && query.endTime) { |
| | | this.dateRange = [query.startTime, query.endTime]; |
| | | } |
| | | this.getList(); |
| | | }, |
| | |
| | | padding: "2px 6px", |
| | | borderRadius: "3px", |
| | | }); |
| | | |
| | | marker = new BMap.Marker(bdPoint,{rotation:direction}); |
| | | marker.setLabel(label); |
| | | } else { |
| | | // 终点显示车辆图标 |
| | | |
| | | const myIcon = new BMap.Icon( |
| | | "/car_blue.png", |
| | | new BMap.Size(20, 20), |
| | |
| | | rotation: direction, |
| | | }); |
| | | } |
| | | //在车图标上显示车牌 |
| | | const label = new BMap.Label(currentSegment[index].vehicleNo, { |
| | | offset: new BMap.Size(0, -25), // 向上偏移25像素 |
| | | position: bdPoint, |
| | | }); |
| | | label.setStyle({ |
| | | color: "white", |
| | | fontSize: "12px", |
| | | backgroundColor: "#3388ff", |
| | | border: "none", |
| | | padding: "2px 6px", |
| | | borderRadius: "3px", |
| | | }); |
| | | marker.setLabel(label); |
| | | |
| | | // 获取地址信息 |
| | | const geoc = new BMap.Geocoder(); |
| | |
| | | addComp.street + |
| | | addComp.streetNumber; |
| | | |
| | | // 添加信息窗口 |
| | | const infoWindow = new BMap.InfoWindow( |
| | | `时间:${item.collectTime}<br/>速度:${ |
| | | item.speed |
| | | }km/h<br/>方向:${item.direction}°<br/>地址:${address}` |
| | | ); |
| | | // 添加点击事件监听器 |
| | | marker.addEventListener("click", () => { |
| | | // 创建信息窗口 |
| | | const infoWindow = new BMap.InfoWindow( |
| | | `时间:${currentSegment[index].collectTime}<br/>速度:${ |
| | | currentSegment[index].speed |
| | | }km/h<br/>方向:${currentSegment[index].direction}°<br/>地址:${address}` |
| | | ); |
| | | this.map.openInfoWindow(infoWindow, bdPoint); |
| | | }); |
| | | }); |
| | |
| | | }); |
| | | marker.setLabel(label); |
| | | |
| | | // 添加信息窗口 |
| | | const infoWindow = new BMap.InfoWindow( |
| | | `时间:${row.collectTime}<br/>速度:${row.speed}km/h<br/>方向:${row.direction}°<br/>地址:${row.address}` |
| | | ); |
| | | marker.addEventListener("click", () => { |
| | | this.map.openInfoWindow(infoWindow, data.points[0]); |
| | | // 获取地址信息 |
| | | const geoc = new BMap.Geocoder(); |
| | | geoc.getLocation(data.points[0], (rs) => { |
| | | const addComp = rs.addressComponents; |
| | | const address = |
| | | addComp.province + |
| | | addComp.city + |
| | | addComp.district + |
| | | addComp.street + |
| | | addComp.streetNumber; |
| | | |
| | | // 添加点击事件监听器 |
| | | marker.addEventListener("click", () => { |
| | | // 创建信息窗口 |
| | | const infoWindow = new BMap.InfoWindow( |
| | | `时间:${row.collectTime}<br/>速度:${row.speed}km/h<br/>方向:${row.direction}°<br/>地址:${address}` |
| | | ); |
| | | this.map.openInfoWindow(infoWindow, data.points[0]); |
| | | }); |
| | | }); |
| | | |
| | | // 保存当前标记点引用 |
| | |
| | | convertor.translate([point], 1, 5, (data) => { |
| | | if (data.status === 0) { |
| | | const bdPoint = data.points[0]; |
| | | //显示车辆图标 |
| | | const myIcon = new BMap.Icon( |
| | | "/car_blue.png", |
| | | new BMap.Size(20, 20), |
| | | { |
| | | imageSize: new BMap.Size(20, 20), |
| | | anchor: new BMap.Size(10, 10), |
| | | } |
| | | ); |
| | | const marker = new BMap.Marker(bdPoint, { |
| | | icon: myIcon, |
| | | rotation: item.direction, |
| | | }); |
| | | // 移除之前的标记点 |
| | | if (this.currentMarker) { |
| | | this.map.removeOverlay(this.currentMarker); |
| | | } |
| | | this.currentMarker=marker; |
| | | this.map.addOverlay(marker); |
| | | this.map.setCenter(bdPoint); |
| | | this.map.setZoom(15); |
| | | } |