|
|
@@ -22,6 +22,7 @@ import add from '@/views/car/carInfo/add.vue';
|
|
|
const path = ref([]);
|
|
|
const current_position = ref([]);
|
|
|
let mapObj = ref()
|
|
|
+let singleMarker = ref(null);
|
|
|
|
|
|
const lineObj = ref(null);
|
|
|
|
|
|
@@ -33,7 +34,7 @@ const getDictsData = (param) => {
|
|
|
// console.log(obj.toString())
|
|
|
var location = formatGCJ(Number(obj[0]), Number(obj[1]));
|
|
|
// console.log(location.toString())
|
|
|
- addMarker(location, res.data[index])
|
|
|
+ addMarker(location, res.data[index], '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png', 'location')
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -43,6 +44,14 @@ const getGpsDataList = (param) => {
|
|
|
getGpsData(param).then(res => {
|
|
|
console.log(res);
|
|
|
addLine(res.rows);
|
|
|
+ if (singleMarker.value != null) {
|
|
|
+ mapObj.value.remove(singleMarker.value);
|
|
|
+ }
|
|
|
+ var car = res.rows[res.rows.length - 1]
|
|
|
+ if (car) {
|
|
|
+ var location = formatGCJ(car.lng, car.lat);
|
|
|
+ addMarker(location, car, "../src/assets/images/icon/小货车.png", 'car')
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -119,10 +128,10 @@ const initMap = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const addMarker = (obj, data) => {
|
|
|
+const addMarker = (obj, data, src, type) => {
|
|
|
const marker = new AMap.Marker({
|
|
|
icon: new AMap.Icon({
|
|
|
- image: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
|
|
|
+ image: src,
|
|
|
imageSize: new AMap.Size(22, 28) //图标大小
|
|
|
}),
|
|
|
position: obj, // 这里我们通过上面的点击获取经纬度坐标,实时添加标记
|
|
|
@@ -133,6 +142,9 @@ const addMarker = (obj, data) => {
|
|
|
offset: new AMap.Pixel(-30, 20),
|
|
|
content: data.dictLabel
|
|
|
});
|
|
|
+ if (type == 'car') {
|
|
|
+ singleMarker.value = marker
|
|
|
+ }
|
|
|
marker.setMap(mapObj.value);
|
|
|
//给marker添加属性
|
|
|
marker.setExtData(data)
|