|
@ -2,6 +2,7 @@ import { loadAMap } from "@screen/pages/Home/components/AMapContainer/loadAMap.j |
|
|
// import { Message } from "element-ui";
|
|
|
// import { Message } from "element-ui";
|
|
|
import Vue from "vue"; |
|
|
import Vue from "vue"; |
|
|
import { lngLatMap } from "./buttonEvent"; |
|
|
import { lngLatMap } from "./buttonEvent"; |
|
|
|
|
|
import { upperFirst } from "lodash"; |
|
|
/** |
|
|
/** |
|
|
* @typedef {Object} Point |
|
|
* @typedef {Object} Point |
|
|
* @property {number} weight - The weight of the item. |
|
|
* @property {number} weight - The weight of the item. |
|
@ -252,26 +253,24 @@ export class MarkerCluster { |
|
|
const findIndex = this.data.findIndex( |
|
|
const findIndex = this.data.findIndex( |
|
|
(removeData) => removeData === item |
|
|
(removeData) => removeData === item |
|
|
); |
|
|
); |
|
|
const { stakeMark } = item.extData; |
|
|
let { stakeMark } = item.extData; |
|
|
|
|
|
stakeMark = upperFirst(stakeMark); //统一格式 大写K
|
|
|
const existNode = graphInstance.getCellById(stakeMark); |
|
|
const existNode = graphInstance.getCellById(stakeMark); |
|
|
const lnglat = item.lnglat; |
|
|
const lnglat = item.lnglat; |
|
|
if (lnglat) { |
|
|
if (lnglat) { |
|
|
const { lat, lng } = getLatAndLng(lnglat); |
|
|
const { lat, lng } = getLatAndLng(lnglat); |
|
|
const lngLatStr = `${lng}/${lat}`; |
|
|
const lngLatStr = `${lng}/${lat}`; |
|
|
const lngLatArr = lngLatMap[lngLatStr]; //已是移除后的数据集
|
|
|
const lngLatArr = lngLatMap[lngLatStr]; //已是移除后的数据集
|
|
|
console.log(lngLatArr, lngLatArr?.length, "length"); |
|
|
|
|
|
if (existNode) { |
|
|
if (existNode) { |
|
|
window.graphInstance.removeNode(existNode.id); |
|
|
|
|
|
if (lngLatArr) { |
|
|
if (lngLatArr) { |
|
|
if (lngLatArr.length === 0) console.log(); |
|
|
if (lngLatArr.length === 0) |
|
|
// window.graphInstance.removeNode(stakeMark);
|
|
|
window.graphInstance.removeNode(existNode.id); |
|
|
else { |
|
|
else { |
|
|
//移除并重新添加
|
|
|
//更新节点
|
|
|
// window.graphInstance.removeNode(stakeMark);
|
|
|
const updateNode = graphInstance.getCellById(stakeMark); |
|
|
console.log("重新ADD", lngLatArr); |
|
|
updateNode.updateData(getDataConf(lngLatArr, item.extData)); |
|
|
// addInGraphHandle(lngLatArr);
|
|
|
|
|
|
} |
|
|
} |
|
|
} //else window.graphInstance.removeNode(stakeMark);
|
|
|
} else window.graphInstance.removeNode(stakeMark); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (findIndex > -1) this.data.splice(findIndex, 1); |
|
|
if (findIndex > -1) this.data.splice(findIndex, 1); |
|
@ -373,11 +372,11 @@ export function marksAddInGraph(data) { |
|
|
|
|
|
|
|
|
export function addInGraphHandle(data) { |
|
|
export function addInGraphHandle(data) { |
|
|
const graphInstance = window.graphInstance; |
|
|
const graphInstance = window.graphInstance; |
|
|
const nowBg = getState(data) ? normalBg : faultBg; |
|
|
|
|
|
const extData = data[0].extData; |
|
|
const extData = data[0].extData; |
|
|
const { item: eventItem } = data[0].config; |
|
|
const { item: eventItem } = data[0].config; |
|
|
if (eventItem.id.match("./事件专题")) { |
|
|
if (eventItem.id.match("./事件专题")) { |
|
|
let { stakeMark, lang } = extData; |
|
|
let { stakeMark, lang } = extData; |
|
|
|
|
|
stakeMark = upperFirst(stakeMark); //统一格式 大写K
|
|
|
const distance = |
|
|
const distance = |
|
|
(Number( |
|
|
(Number( |
|
|
stakeMark.replace(/\.\d+/, "").replace("+", ".").replace(/[Kk]/, "") |
|
|
stakeMark.replace(/\.\d+/, "").replace("+", ".").replace(/[Kk]/, "") |
|
@ -386,28 +385,12 @@ export function addInGraphHandle(data) { |
|
|
window.canvasRatio + |
|
|
window.canvasRatio + |
|
|
window.canvasWidth * window.offsetRatio; //K54+394 开始到K208+979计算的比例尺
|
|
|
window.canvasWidth * window.offsetRatio; //K54+394 开始到K208+979计算的比例尺
|
|
|
|
|
|
|
|
|
const node = {}; |
|
|
const node = { shape: "custom-html", effect: ["data"] }; |
|
|
if (data.length === 1) { |
|
|
node.data = getDataConf(data, extData); |
|
|
node.shape = "singleNode-html"; |
|
|
|
|
|
node.data = { |
|
|
|
|
|
nowBg, |
|
|
|
|
|
src: `${getIcon(data[0])}`, |
|
|
|
|
|
extData, |
|
|
|
|
|
}; |
|
|
|
|
|
} else { |
|
|
|
|
|
node.shape = "multiNode-html"; |
|
|
|
|
|
node.data = { |
|
|
|
|
|
nowBg, |
|
|
|
|
|
// width: `${36 + `${data.length}`.length * 15}px`,
|
|
|
|
|
|
length: data.length, |
|
|
|
|
|
extData, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
const existNode = graphInstance.getCellById(stakeMark); |
|
|
const existNode = graphInstance.getCellById(stakeMark); |
|
|
if (existNode) { |
|
|
if (existNode) { |
|
|
graphInstance.removeCell(existNode.id); |
|
|
existNode.updateData(node.data); |
|
|
} |
|
|
} else { |
|
|
console.log(lang, "lang"); |
|
|
|
|
|
// setTimeout(() => {
|
|
|
// setTimeout(() => {
|
|
|
graphInstance.addNode({ |
|
|
graphInstance.addNode({ |
|
|
x: distance, |
|
|
x: distance, |
|
@ -420,6 +403,30 @@ export function addInGraphHandle(data) { |
|
|
}); |
|
|
}); |
|
|
// }, 0);
|
|
|
// }, 0);
|
|
|
} |
|
|
} |
|
|
|
|
|
console.log(lang, "lang"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getDataConf(data, extData) { |
|
|
|
|
|
let dataConf; |
|
|
|
|
|
const nowBg = getState(data) ? normalBg : faultBg; |
|
|
|
|
|
if (data.length === 1) { |
|
|
|
|
|
dataConf = { |
|
|
|
|
|
shape: "singleNode-html", |
|
|
|
|
|
nowBg, |
|
|
|
|
|
src: `${getIcon(data[0])}`, |
|
|
|
|
|
extData, |
|
|
|
|
|
}; |
|
|
|
|
|
} else { |
|
|
|
|
|
dataConf = { |
|
|
|
|
|
shape: "multiNode-html", |
|
|
|
|
|
nowBg, |
|
|
|
|
|
// width: `${36 + `${data.length}`.length * 15}px`,
|
|
|
|
|
|
length: data.length, |
|
|
|
|
|
extData, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
return dataConf; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function getLatAndLng(lnglat) { |
|
|
export function getLatAndLng(lnglat) { |
|
|