Commit 8a11cf06 by chenwq

多个点一致,标记点

1 parent 91331fba
......@@ -342,7 +342,7 @@ export default defineComponent({
// replayData.push(lnglat);
// });
data.reduce(function(prev ,item ){
console.log(prev ,item)
// console.log(prev ,item)
let prevLnglat=mapContentRefs.value.getLngLat(prev[0], prev[1])
let lnglat=mapContentRefs.value.getLngLat(item[0], item[1])
replay.dis.push(window.mapapi.invoke("getDistance", prevLnglat, lnglat))
......@@ -365,44 +365,55 @@ export default defineComponent({
replay.distance=replay.dis.reduce(function (prev, cur, index, arr) {
return prev + cur;
});
replay.distance=replay.distance/1000//算出轨迹的距离(km)
const firstItem = data[0];
replay.navg = window.mapapi.invoke("LuShu", replayData, {
// defaultContent: getNavgInfoContent(firstItem),
autoView: true, // 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
speed: getSpeed(replay.speed, replay.distance),
// speed: 300,
icon: window.mapapi.invoke(
"Icon",
require("@/assets/images/car0.png"),
window.mapapi.invoke("Size", 26, 17),
// { anchor: window.mapapi.invoke("Size", 24, 24) }
),
enableRotation: true, // 是否设置marker随着道路的走向进行旋转
});
// window.mapapi.invoke("lushuStart"); //开始
// AMap.invoke('lushuStop') //停止
// AMap.invoke('lushuPause') //暂停
// AMap.invoke('lushuShowInfoWindow') //打开信息窗口
// EventBus.$emit("uiMap.replay.initDone");
window.mapapi.invoke("lushuAddEventListener", "move", (e) => {
if(e.target.i){
idx.value = e.target.i
}
// let lnglat = replayData[idx.value];
// let item = data[idx.value];
// window.mapapi.invoke("lushuSetContent", replay.getNavgInfoContent(item)); //设置信息窗口文案
// EventBus.$emit("uiMap.replay.currAddress", "");
// console.log(idx.value, data.length - 1);
// if (idx.value >= data.length - 2) {
// EventBus.$emit("uiMap.replay.done");
// }
});
if(replay.distance){
replay.distance=replay.distance/1000//算出轨迹的距离(km)
const firstItem = data[0];
replay.navg = window.mapapi.invoke("LuShu", replayData, {
// defaultContent: getNavgInfoContent(firstItem),
autoView: true, // 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
speed: getSpeed(replay.speed, replay.distance),
// speed: 300,
icon: window.mapapi.invoke(
"Icon",
require("@/assets/images/car0.png"),
window.mapapi.invoke("Size", 26, 17),
// { anchor: window.mapapi.invoke("Size", 24, 24) }
),
enableRotation: true, // 是否设置marker随着道路的走向进行旋转
});
// window.mapapi.invoke("lushuStart"); //开始
// AMap.invoke('lushuStop') //停止
// AMap.invoke('lushuPause') //暂停
// AMap.invoke('lushuShowInfoWindow') //打开信息窗口
// EventBus.$emit("uiMap.replay.initDone");
window.mapapi.invoke("lushuAddEventListener", "move", (e) => {
if(e.target.i){
idx.value = e.target.i
}
// let lnglat = replayData[idx.value];
// let item = data[idx.value];
// window.mapapi.invoke("lushuSetContent", replay.getNavgInfoContent(item)); //设置信息窗口文案
// EventBus.$emit("uiMap.replay.currAddress", "");
// console.log(idx.value, data.length - 1);
// if (idx.value >= data.length - 2) {
// EventBus.$emit("uiMap.replay.done");
// }
});
window.mapapi.invoke("lushuAddEventListener", "end", (e) => {
isPlay.value = false;
})
window.mapapi.invoke("lushuAddEventListener", "end", (e) => {
isPlay.value = false;
})
} else {
//距离为0时,单独处理
const item = data[ data.length-1];
window.mapapi.invoke('clearOverlays');
// replay.Marker = mapService.createCarMarker(p2, window.mapapi);
let marker = window.mapapi.invoke('Marker', p2, {
icon: window.mapapi.invoke('Icon', require("@/assets/images/curr-marker.gif"), window.mapapi.invoke('Size', 24, 24)),
})
window.mapapi.invoke('addOverlay', marker )
}
// replay.dis = window.AMap.GeometryUtil.distanceOfLine(replayData) / 1000; // 算出轨迹的距离(km)
// if (replay.PathS) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!