fix: polish earth legend and info panel interactions
This commit is contained in:
@@ -1,25 +1,21 @@
|
||||
const LEGEND_MODES = {
|
||||
cables: {
|
||||
title: "线缆图例",
|
||||
items: [
|
||||
{ color: "#ff4444", label: "Americas II" },
|
||||
{ color: "#44ff44", label: "AU Aleutian A" },
|
||||
{ color: "#4444ff", label: "AU Aleutian B" },
|
||||
{ color: "#ffff44", label: "其他电缆" },
|
||||
],
|
||||
},
|
||||
satellites: {
|
||||
title: "卫星图例",
|
||||
items: [
|
||||
{ color: "#4db8ff", label: "卫星本体" },
|
||||
{ color: "#9be7ff", label: "卫星轨迹" },
|
||||
{ color: "#7dffb3", label: "悬停高亮" },
|
||||
{ color: "#ffd166", label: "选中目标" },
|
||||
],
|
||||
},
|
||||
bgp: {
|
||||
title: "BGP观测图例",
|
||||
},
|
||||
};
|
||||
|
||||
let currentLegendMode = "cables";
|
||||
let legendItemsByMode = {
|
||||
cables: [],
|
||||
satellites: [],
|
||||
bgp: [],
|
||||
};
|
||||
|
||||
export function initLegend() {
|
||||
renderLegend(currentLegendMode);
|
||||
@@ -27,7 +23,6 @@ export function initLegend() {
|
||||
|
||||
export function setLegendMode(mode) {
|
||||
const nextMode = LEGEND_MODES[mode] ? mode : "cables";
|
||||
if (nextMode === currentLegendMode) return;
|
||||
currentLegendMode = nextMode;
|
||||
renderLegend(currentLegendMode);
|
||||
}
|
||||
@@ -36,12 +31,25 @@ export function getLegendMode() {
|
||||
return currentLegendMode;
|
||||
}
|
||||
|
||||
export function refreshLegend() {
|
||||
renderLegend(currentLegendMode);
|
||||
}
|
||||
|
||||
export function setLegendItems(mode, items) {
|
||||
if (!LEGEND_MODES[mode]) return;
|
||||
legendItemsByMode[mode] = Array.isArray(items) ? items : [];
|
||||
if (mode === currentLegendMode) {
|
||||
renderLegend(currentLegendMode);
|
||||
}
|
||||
}
|
||||
|
||||
function renderLegend(mode) {
|
||||
const legend = document.getElementById("legend");
|
||||
if (!legend) return;
|
||||
|
||||
const config = LEGEND_MODES[mode] || LEGEND_MODES.cables;
|
||||
const itemsHtml = config.items
|
||||
const items = legendItemsByMode[mode] || [];
|
||||
const itemsHtml = items
|
||||
.map(
|
||||
(item) => `
|
||||
<div class="legend-item">
|
||||
|
||||
Reference in New Issue
Block a user