| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500 |
- <template>
- <div class="map-wrapper">
- <div ref="mapContainer" class="map-container"></div>
- <div class="map-legend" :style="privateStyle.legend" v-if="(!mode || mode === '路口')"
- :class="{ 'legend-hidden': !legendVisible }">
- <div class="legend-header">
- <div class="legend-title">图例</div>
- <div class="legend-close-btn" @click="toggleLegend">✕</div>
- </div>
- <div class="legend-list">
- <div class="legend-item all-select" @click="toggleAll">
- <div class="legend-dot"
- :style="{ backgroundColor: isAllSelected ? '#fff' : 'transparent', border: '1px solid #fff' }"></div>
- <div class="legend-label" style="font-weight: bold;">全选</div>
- </div>
- <div v-for="item in legendStatusConfig" class="legend-item" @click="toggleRouteVisible(item.name)" :key="item.name"
- :class="{ 'is-inactive': !activeLegends.includes(item.name) }">
- <div class="legend-dot"
- :style="{ backgroundColor: ['离线', '降级', '故障'].includes(item.name) ? 'transparent' : item.color }"
- :class="{ 'special-route': ['干线协调', '勤务路线'].includes(item.name), 'is-status-wrapper': ['离线', '降级', '故障'].includes(item.name) }">
- <span v-if="!['离线', '降级', '故障'].includes(item.name)">
- {{ item.name.charAt(0) }}
- </span>
- <img v-else
- :src="require(`@/assets/images/icon_${item.name === '离线' ? 'lixian' : item.name === '降级' ? 'jiangji' : 'guzhang'}.png`)"
- class="status-icon" />
- </div>
- <div class="legend-label">{{ item.name }}</div>
- </div>
- </div>
- </div>
- <div class="legend-show-btn" v-if="(!mode || mode === '路口') && !legendVisible" @click="toggleLegend" :style="legendShowBtnStyle">
- <div class="legend-show-icon">☰</div>
- </div>
- </div>
- </template>
- <script>
- import AMapLoader from '@amap/amap-jsapi-loader';
- export default {
- name: "TrafficMap",
- props: {
- amapKey: { type: String, default: '您的Key' },
- securityJsCode: { type: String, default: '您的安全密钥' },
- mode: { type: String, default: '', validator: (value) => ['', '路口', '干线', '特勤'].includes(value) }
- },
- data() {
- return {
- AMap: null,
- map: null,
- infoWindow: null,
- routeGroups: {},
- privateStyle: {
- legend: {}
- },
- legendVisible: true,
- activeLegends: ["中心计划", "干线协调", "勤务路线", "定周期控制", "感应控制", "自适应控制", "手动控制", "特殊控制", "离线", "降级", "故障"],
- // 核心修正:增加生命周期标识,防止组件销毁后异步回调继续执行
- isComponentDestroyed: false,
- drawSeq: 0,
- driving: null,
- infoCloseTimer: null,
- activeInfoWindowId: null,
- isInfoWindowHovered: false,
- // 状态类型配置
- statusConfig: [
- { name: "中心计划", color: "#004CDE", type: "normal" },
- { name: "干线协调", color: "#13C373", type: "route" },
- { name: "勤务路线", color: "#BC301D", type: "route" },
- { name: "定周期控制", color: "#3296FA", type: "normal" },
- { name: "感应控制", color: "#FF864C", type: "normal" },
- { name: "自适应控制", color: "#9F6EFE", type: "normal" },
- { name: "手动控制", color: "#EB9F36", type: "normal" },
- { name: "特殊控制", color: "#A26218", type: "normal" },
- { name: "离线", color: "#7A7A7A", type: "abnormal" },
- { name: "降级", color: "#D9C13B", type: "abnormal" },
- { name: "故障", color: "#FF3938", type: "abnormal" }
- ],
- // 真实路口数据
- intersectionData: [],
- // 按状态分类的路口数据
- statusIntersections: {},
- };
- },
- mounted() {
- this.isComponentDestroyed = false; // 重置标识
- this.loadMapData().then(() => {
- this.classifyIntersectionsByStatus();
- this.updateMapByMode();
- this.initAMap();
- // 在数据加载完成后存储坐标
- this.storeStatusCoordsToLocalStorage();
- });
- if (this.$route.path === '/home' || this.$route.path === '/watch') {
- this.privateStyle.legend = { right: "25%" };
- }
- },
- watch: {
- mode: {
- handler() {
- this.updateMapByMode();
- this.updateMapDisplay();
- },
- immediate: false
- }
- },
- beforeDestroy() {
- // 1. 立即设置销毁状态
- this.isComponentDestroyed = true;
- this.drawSeq += 1;
- // 2. 关闭弹窗
- if (this.infoWindow) {
- try {
- this.infoWindow.close();
- } catch (e) {
- console.warn('关闭信息窗口时出错:', e);
- }
- this.infoWindow = null;
- }
- // 3. 清理覆盖物引用
- if (this.routeGroups) {
- Object.values(this.routeGroups).forEach(overlays => {
- if (Array.isArray(overlays)) {
- overlays.forEach(o => {
- try {
- if (o.setMap) o.setMap(null);
- } catch (e) {
- console.warn('清理覆盖物时出错:', e);
- }
- });
- }
- });
- this.routeGroups = {};
- }
- // 4. 销毁地图实例并清空引用
- if (this.map) {
- try {
- this.map.destroy();
- } catch (e) {
- console.warn('销毁地图实例时出错:', e);
- }
- this.map = null;
- }
- // 5. 清理其他引用
- this.AMap = null;
- this.driving = null;
- if (this.infoCloseTimer) {
- clearTimeout(this.infoCloseTimer);
- this.infoCloseTimer = null;
- }
- this.activeInfoWindowId = null;
- this.isInfoWindowHovered = false;
- },
- computed: {
- isAllSelected() {
- return this.activeLegends.length === this.statusConfig.length;
- },
- isHomePage() {
- return this.$route && (this.$route.path === '/home' || this.$route.path === '/surve');
- },
- legendShowBtnStyle() {
- if (!this.isHomePage) return {};
- const right = (this.privateStyle.legend && this.privateStyle.legend.right) ? this.privateStyle.legend.right : '25%';
- return { right, borderRadius: '6px' };
- },
- legendStatusConfig() {
- if (!this.mode) return this.statusConfig;
- if (this.mode === '路口') {
- return this.statusConfig.filter(item => !['干线协调', '勤务路线'].includes(item.name));
- }
- return [];
- }
- },
- methods: {
- // 动态加载地图数据
- async loadMapData() {
- try {
- const mapDataModule = await import('@/mock/map_data_gaode.json');
- this.intersectionData = mapDataModule.default || [];
- console.log('地图数据加载成功,共', this.intersectionData.length, '个路口');
- } catch (error) {
- console.error('地图数据加载失败:', error);
- this.intersectionData = [];
- }
- },
- // 检查地图环境是否安全可用
- isMapReady() {
- return !this.isComponentDestroyed && this.map && typeof this.map.add === 'function';
- },
- // 将真实路口数据按状态类型分类
- classifyIntersectionsByStatus() {
- const remainingData = this.intersectionData;
- const normalStatusCount = 6;
- const abnormalStatusCount = 3;
- const chunkSize = Math.floor(remainingData.length / (normalStatusCount + abnormalStatusCount));
- const maxAbnormalCount = 4;
- this.statusIntersections = {
- "中心计划": remainingData.slice(0, 20),
- "干线协调": [], // 清空,改为动态生成
- "勤务路线": [], // 清空,改为动态生成
- "定周期控制": remainingData.slice(chunkSize, chunkSize * 2),
- "感应控制": remainingData.slice(chunkSize * 2, chunkSize * 3),
- "自适应控制": remainingData.slice(chunkSize * 3, chunkSize * 4),
- "手动控制": remainingData.slice(chunkSize * 4, chunkSize * 5),
- "特殊控制": remainingData.slice(chunkSize * 5, chunkSize * 6),
- "离线": remainingData.slice(chunkSize * 6, Math.min(chunkSize * 7, chunkSize * 6 + maxAbnormalCount)),
- "降级": remainingData.slice(chunkSize * 7, Math.min(chunkSize * 8, chunkSize * 7 + maxAbnormalCount)),
- "故障": remainingData.slice(chunkSize * 8, Math.min(chunkSize * 9, chunkSize * 8 + maxAbnormalCount))
- };
- },
- updateMapByMode() {
- switch (this.mode) {
- case '路口':
- this.activeLegends = ["中心计划", "定周期控制", "感应控制", "自适应控制", "手动控制", "特殊控制", "离线", "降级", "故障"];
- break;
- case '干线':
- this.activeLegends = ["干线协调"];
- break;
- case '特勤':
- this.activeLegends = ["勤务路线"];
- break;
- default:
- this.activeLegends = this.statusConfig.map(item => item.name);
- }
- },
- updateMapDisplay() {
- if (this.infoWindow) this.infoWindow.close();
- if (!this.isMapReady()) return;
- Object.keys(this.routeGroups).forEach(name => {
- const overlays = this.routeGroups[name];
- if (overlays && overlays.length > 0) {
- if (this.activeLegends.includes(name)) {
- this.map.add(overlays);
- } else {
- this.map.remove(overlays);
- }
- }
- });
- },
- async initAMap() {
- if (this.isComponentDestroyed) return;
- // 确保在加载前注入
- window._AMapSecurityConfig = { securityJsCode: this.securityJsCode };
- try {
- const AMap = await AMapLoader.load({
- key: this.amapKey,
- version: "2.0",
- // 核心:确保 Driving 插件在此加载
- plugins: ['AMap.Driving']
- });
- if (this.isComponentDestroyed) return;
- this.AMap = AMap;
- this.map = new AMap.Map(this.$refs.mapContainer, {
- zoom: 15,
- mapStyle: "amap://styles/darkblue",
- center: [116.663, 39.905], // 通州区中心
- });
- this.driving = new AMap.Driving({ map: null, hideMarkers: true });
- // 建议在地图加载完成后再画线
- this.map.on('complete', () => {
- if (!this.isComponentDestroyed) {
- this.drawStaticRoutes();
- }
- });
- } catch (err) {
- console.error('地图加载失败:', err);
- }
- },
- // 绘制静态路线和标记
- // 对于普通状态,从 mock 数据加载路口标记
- // 对于路线类(干线协调和勤务路线),使用高德地图路线规划绘制路线和密集点位
- async drawStaticRoutes() {
- if (!this.isMapReady()) return;
- this.drawSeq += 1;
- const drawSeq = this.drawSeq;
- this.clearAllRouteOverlays();
- const realRouteConfigs = {
- "干线协调": [
- { start: [116.6421, 39.9272], end: [116.6825, 39.9272], color: "#13C373" },
- { start: [116.6426, 39.9221], end: [116.6830, 39.9221], color: "#13C373" },
- { start: [116.6432, 39.9171], end: [116.6833, 39.9171], color: "#13C373" },
- { start: [116.6438, 39.9123], end: [116.6841, 39.9123], color: "#13C373" },
- { start: [116.6445, 39.9075], end: [116.6846, 39.9075], color: "#13C373" }
- ],
- "勤务路线": [
- { start: [116.7120, 39.9225], end: [116.7120, 39.8971], color: "#BC301D" }
- ]
- };
- for (const config of this.statusConfig) {
- if (this.isComponentDestroyed || drawSeq !== this.drawSeq) return;
- // 1. 处理普通非路线状态(从 mock 数据加载)
- if (!realRouteConfigs[config.name]) {
- const intersections = this.statusIntersections[config.name] || [];
- const markers = intersections.map(item =>
- this.createTrafficLightMarker([item["位置-经度"], item["位置-纬度"]], {
- ...config,
- road: item["路口名称"] || '规划路口'
- })
- ).filter(Boolean);
- this.routeGroups[config.name] = markers;
- if (this.activeLegends.includes(config.name)) this.map.add(markers);
- continue;
- }
- // 2. 处理路线类(干线/特勤)
- this.routeGroups[config.name] = [];
- const lines = realRouteConfigs[config.name] || [];
- const trunkSegments = [];
- for (let lineIdx = 0; lineIdx < lines.length; lineIdx += 1) {
- if (this.isComponentDestroyed || drawSeq !== this.drawSeq) return;
- const line = lines[lineIdx];
- let path = null;
- try {
- path = await this.searchDrivingPathWithRetry(line.start, line.end);
- } catch (e) {
- path = null;
- }
- const overlays = this.buildRouteOverlaysFromPath({
- config,
- configName: config.name,
- line,
- lineIdx,
- path
- });
- // 统计干线协调实际生成的线段数
- if (config.name === '干线协调' && overlays.length > 0) {
- const trunkNames = [
- '古城南路与古城大街', '古城西路东口南一过街', '古城大街与古城北路',
- '八角北路与八角东街', '古城西路与古城大街'
- ];
- const polylineCount = overlays.filter(o => o instanceof this.AMap.Polyline).length;
- for (let s = 0; s < polylineCount; s++) {
- const idx = trunkSegments.length + 1;
- const name = trunkNames[idx - 1] || ('干线' + idx);
- trunkSegments.push({
- id: 'trunk_' + idx,
- label: name,
- intersections: Array.from({ length: 6 }, (_, k) => name + '_路口' + (k + 1)),
- distances: Array.from({ length: 6 }, (_, k) => k * 1000),
- _lineIdx: lineIdx,
- _segmentIdx: s
- });
- }
- }
- if (this.isComponentDestroyed || drawSeq !== this.drawSeq) return;
- if (overlays.length > 0) {
- this.routeGroups[config.name].push(...overlays);
- if (this.activeLegends.includes(config.name)) this.map.add(overlays);
- }
- await this.sleep(80);
- }
- // 干线协调绘制完成后,通知父组件用于菜单渲染
- if (config.name === '干线协调' && trunkSegments.length > 0) {
- this.$emit('bindTrunkMenuTree', trunkSegments);
- }
- }
- },
- clearAllRouteOverlays() {
- if (!this.isMapReady()) return;
- try {
- if (this.infoWindow) this.infoWindow.close();
- } catch (e) {
- void e;
- }
- Object.values(this.routeGroups || {}).forEach(overlays => {
- if (!Array.isArray(overlays) || overlays.length === 0) return;
- try {
- this.map.remove(overlays);
- } catch (e) {
- void e;
- }
- overlays.forEach(o => {
- try {
- if (o && typeof o.setMap === 'function') o.setMap(null);
- } catch (e) {
- void e;
- }
- });
- });
- this.routeGroups = {};
- },
- sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- },
- async searchDrivingPathWithRetry(start, end) {
- if (!this.AMap || !this.driving || typeof this.driving.search !== 'function') {
- throw new Error('Driving not ready');
- }
- const maxAttempts = 3;
- let lastErr = null;
- for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
- try {
- return await this.withTimeout(this.searchDrivingPathOnce(start, end), 8000);
- } catch (e) {
- lastErr = e;
- await this.sleep(250 * attempt);
- }
- }
- throw lastErr || new Error('Driving search failed');
- },
- searchDrivingPathOnce(start, end) {
- return new Promise((resolve, reject) => {
- this.driving.search(start, end, (status, result) => {
- const route = result && result.routes && result.routes[0];
- if (status === 'complete' && route && Array.isArray(route.steps)) {
- const fullPath = [];
- route.steps.forEach(step => {
- if (step && Array.isArray(step.path)) fullPath.push(...step.path);
- });
- if (fullPath.length >= 2) resolve(fullPath);
- else reject(new Error('empty_path'));
- return;
- }
- reject(new Error(typeof status === 'string' ? status : 'driving_error'));
- });
- });
- },
- withTimeout(promise, timeoutMs) {
- return Promise.race([
- promise,
- new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), timeoutMs))
- ]);
- },
- buildRouteOverlaysFromPath({ config, configName, line, lineIdx, path }) {
- if (!this.AMap || !this.map) return [];
- let basePath = path;
- if (!Array.isArray(basePath) || basePath.length < 2) {
- basePath = this.buildFallbackLinePath(line.start, line.end, 30);
- }
- // --- 核心优化:确保线路准确贴合真实道路 ---
- // 取消原本的微小物理解散偏移,以保证所有线路(包含但不限单条调整后)严格绘制在导航真实道路上
- const offsetVal = 0;
- const applyOffset = (p) => {
- const lng = p.lng || (p.getLng ? p.getLng() : (Array.isArray(p) ? Number(p[0]) : 0));
- const lat = p.lat || (p.getLat ? p.getLat() : (Array.isArray(p) ? Number(p[1]) : 0));
- return [lng + offsetVal, lat + offsetVal];
- };
- const segments = this.extractMainStraightSegments(basePath);
- const overlays = [];
- segments.forEach((rawSegmentPath, segmentIdx) => {
- if (!Array.isArray(rawSegmentPath) || rawSegmentPath.length < 2) return;
- // 应用偏移到当前段的所有点
- const segmentPath = rawSegmentPath.map(p => applyOffset(p));
- const polyline = new this.AMap.Polyline({
- path: segmentPath,
- strokeColor: line.color,
- strokeWeight: 6,
- strokeOpacity: 0.8,
- zIndex: 15
- });
- overlays.push(polyline);
- const totalPoints = segmentPath.length;
- // --- 核心优化:全路段物理距离均匀放置方向箭头 ---
- // 1. 计算整条 segmentPath 的总物理距离及每个点的累计距离
- const pathDistances = [0];
- let totalPathDist = 0;
- for (let j = 0; j < totalPoints - 1; j++) {
- const d = this.calcApproxDistance(segmentPath[j], segmentPath[j+1]);
- totalPathDist += d;
- pathDistances.push(totalPathDist);
- }
- // 2. 设定标准间距:约每 0.0018 度 (约 200 米) 放置一个箭头
- if (configName !== '干线协调') {
- const targetSpacing = 0.0018;
- let currentTargetDist = targetSpacing / 2; // 第一个箭头放在 1/2 间距处,让分布更美观
- while (currentTargetDist < totalPathDist) {
- // 3. 寻找对应 targetDist 的路径位置 (线性插值)
- let foundIdx = 0;
- for (let j = 0; j < pathDistances.length - 1; j++) {
- if (currentTargetDist >= pathDistances[j] && currentTargetDist <= pathDistances[j + 1]) {
- foundIdx = j;
- break;
- }
- }
- const p1 = segmentPath[foundIdx];
- const p2 = segmentPath[foundIdx + 1];
- if (p1 && p2) {
- // 在 p1 和 p2 之间线性插值
- const ratio = (currentTargetDist - pathDistances[foundIdx]) / (pathDistances[foundIdx + 1] - pathDistances[foundIdx]);
- const lng1 = Number(p1[0]);
- const lat1 = Number(p1[1]);
- const lng2 = Number(p2[0]);
- const lat2 = Number(p2[1]);
- const midLng = lng1 + (lng2 - lng1) * ratio;
- const midLat = lat1 + (lat2 - lat1) * ratio;
- const bearing = this.calcBearingDeg(p1, p2);
- const rotation = bearing - 90;
- const directionMarker = new this.AMap.Marker({
- position: [midLng, midLat],
- content: `
- <div style="transform: rotate(${rotation}deg); width: 20px; height: 10px; display: flex; align-items: center; pointer-events: none; opacity: 0.85;">
- <img src="${require('@/assets/map/direction.png')}" style="width: 100%; height: auto;" />
- </div>
- `,
- offset: new this.AMap.Pixel(-10, -5),
- zIndex: 20,
- bubble: true
- });
- overlays.push(directionMarker);
- }
- currentTargetDist += targetSpacing;
- }
- }
- // 为圆点保留原来的分布 logic (不受箭头影响)
- const indices = this.pickEvenlySpacedIndices(totalPoints, 6);
- // 为第一个和最后一个圆点设置特殊类型
- for (let i = 0; i < indices.length; i++) {
- const idx = indices[i];
- const p = segmentPath[idx];
- const lng = Number(p[0]);
- const lat = Number(p[1]);
- if (Number.isNaN(lng) || Number.isNaN(lat)) continue;
- // 确定圆点类型:勤务路线保留起终点,干线协调移除起终点图标改为普通节点
- let markerType = 'normal';
- if (configName !== '干线协调') {
- if (i === 0) {
- markerType = 'start';
- } else if (i === indices.length - 1) {
- markerType = 'end';
- }
- }
- const marker = this.createTrafficLightMarker([lng, lat], {
- ...config,
- id: `MOCK-${configName.charAt(0)}-${lineIdx}-${segmentIdx}-${idx}`,
- road: `${configName}路口-${lineIdx}-${segmentIdx}-${idx}`
- }, markerType);
- if (marker) overlays.push(marker);
- }
- });
- return overlays;
- },
- pickEvenlySpacedIndices(totalPoints, count) {
- const total = Math.max(Number(totalPoints) || 0, 0);
- const target = Math.max(Number(count) || 0, 0);
- if (total <= 0 || target <= 0) return [];
- if (target >= total) return Array.from({ length: total }, (_, i) => i);
- if (target === 1) return [0];
- return Array.from({ length: target }, (_, k) => Math.round((k * (total - 1)) / (target - 1)));
- },
- buildFallbackLinePath(start, end, pointCount) {
- const sLng = Number(start && start[0]);
- const sLat = Number(start && start[1]);
- const eLng = Number(end && end[0]);
- const eLat = Number(end && end[1]);
- const n = Math.max(Number(pointCount) || 2, 2);
- const path = [];
- if ([sLng, sLat, eLng, eLat].some(v => Number.isNaN(v))) return path;
- for (let i = 0; i < n; i += 1) {
- const t = n === 1 ? 0 : i / (n - 1);
- const lng = sLng + (eLng - sLng) * t;
- const lat = sLat + (eLat - sLat) * t;
- path.push({ lng, lat });
- }
- return path;
- },
- extractMainStraightSegments(path) {
- const getCoord = (p) => {
- if (!p) return { lng: NaN, lat: NaN };
- if (Array.isArray(p)) return { lng: Number(p[0]), lat: Number(p[1]) };
- if (p.getLng) return { lng: p.getLng(), lat: p.getLat() };
- return { lng: Number(p.lng), lat: Number(p.lat) };
- };
- const points = (path || []).map(p => getCoord(p)).filter(p => !isNaN(p.lng) && !isNaN(p.lat));
- if (points.length < 2) return [];
- const thresholdDeg = 18;
- const segments = [];
- let curStart = 0;
- let curAngle = null;
- let curLen = 0;
- const pushSegment = (endIdx) => {
- if (endIdx <= curStart) return;
- segments.push({
- start: curStart,
- end: endIdx,
- len: curLen
- });
- };
- for (let i = 0; i < points.length - 1; i += 1) {
- const a = points[i];
- const b = points[i + 1];
- const len = this.calcApproxDistance(a, b);
- if (len <= 0) continue;
- const angle = this.calcBearingDeg(a, b);
- if (curAngle === null) {
- curStart = i;
- curAngle = angle;
- curLen = len;
- continue;
- }
- const diff = this.calcAngleDiffDeg(curAngle, angle);
- if (diff <= thresholdDeg) {
- curLen += len;
- } else {
- pushSegment(i);
- curStart = i;
- curAngle = angle;
- curLen = len;
- }
- }
- pushSegment(points.length - 2);
- if (segments.length === 0) return [points];
- segments.sort((s1, s2) => s2.len - s1.len);
- const maxLen = segments[0].len || 0;
- const filtered = segments.filter(s => s.len >= maxLen * 0.55).slice(0, 3);
- const finalSegments = filtered.map(s => points.slice(s.start, s.end + 2));
- return finalSegments.length > 0 ? finalSegments : [points];
- },
- // 内部通用工具:从不同格式的点中提取经纬度数组 [lng, lat]
- _getCoords(p) {
- if (!p) return [0, 0];
- const lng = p.lng || (p.getLng ? p.getLng() : (Array.isArray(p) ? Number(p[0]) : 0));
- const lat = p.lat || (p.getLat ? p.getLat() : (Array.isArray(p) ? Number(p[1]) : 0));
- return [lng, lat];
- },
- calcBearingDeg(a, b) {
- const [alng, alat] = this._getCoords(a);
- const [blng, blat] = this._getCoords(b);
- const latRad = ((alat + blat) / 2) * Math.PI / 180;
- const dx = (blng - alng) * Math.cos(latRad);
- const dy = (blat - alat);
-
- const mathAngle = Math.atan2(dy, dx) * 180 / Math.PI;
- return (90 - mathAngle + 360) % 360;
- },
- calcAngleDiffDeg(a, b) {
- let diff = Math.abs(a - b);
- if (diff > 180) diff = 360 - diff;
- return diff;
- },
- calcApproxDistance(a, b) {
- const [alng, alat] = this._getCoords(a);
- const [blng, blat] = this._getCoords(b);
- const latRad = ((alat + blat) / 2) * Math.PI / 180;
- const dx = (blng - alng) * Math.cos(latRad);
- const dy = (blat - alat);
- return Math.sqrt(dx * dx + dy * dy);
- },
- createTrafficLightMarker(position, config, type = 'normal') {
- if (!position || !config) return null;
- try {
- const lng = position.getLng ? position.getLng() : Number(position[0] !== undefined ? position[0] : position.lng);
- const lat = position.getLat ? position.getLat() : Number(position[1] !== undefined ? position[1] : position.lat);
- if (isNaN(lng) || isNaN(lat)) return null;
- // 状态文字:起、终、或者状态配置的首字母
- let displayText = config.name ? config.name.charAt(0) : '';
- if (type === 'start') displayText = '起';
- if (type === 'end') displayText = '终';
- const isAbnormal = ["离线", "降级", "故障"].includes(config.name);
- const isRoute = ["干线协调", "勤务路线"].includes(config.name);
- const isStartEnd = type === 'start' || type === 'end';
- // 核心配置映射:减少嵌套逻辑
- const markerStyle = isStartEnd ? {
- size: '24px',
- height: '30px',
- offset: [-12, -30],
- zIndex: 120,
- border: '2px solid #fff'
- } : (isAbnormal ? {
- size: '30px',
- height: '30px',
- offset: [-15, -15],
- zIndex: 110,
- border: 'none'
- } : {
- size: '14px',
- height: '14px',
- offset: [-9, -9], // 14px + 2px padding * 2 = 18px total
- zIndex: 100,
- border: isRoute ? 'none' : '1.5px solid rgba(255,255,255,0.7)'
- });
- // 生成标记内容
- let markerContent = '';
- if (isStartEnd) {
- markerContent = `
- <div class="pure-light-node start-end-node" style="width: ${markerStyle.size}; height: ${markerStyle.height}; background: transparent; border: none; display: flex; justify-content: center; align-items: flex-end; cursor: pointer; transform-origin: bottom center;">
- <img src="${require(`@/assets/map/${type}.png`)}" style="width: 100%; height: auto; object-fit: contain; pointer-events: none;" />
- </div>
- `;
- } else if (isAbnormal) {
- const iconName = config.name === '离线' ? 'lixian' : config.name === '降级' ? 'jiangji' : 'guzhang';
- markerContent = `
- <div class="pure-light-node breathe" style="width: ${markerStyle.size}; height: ${markerStyle.height}; background: transparent; border: none; box-sizing: content-box; display: flex; justify-content: center; align-items: center; cursor: pointer; padding: 0;">
- <img src="${require(`@/assets/images/icon_${iconName}.png`)}" style="width: 100%; height: 100%; object-fit: contain;" />
- </div>
- `;
- } else {
- markerContent = `
- <div class="pure-light-node ${isRoute ? 'route-node' : ''}" style="width: ${markerStyle.size}; height: ${markerStyle.height}; background: ${config.color || '#999'}; box-shadow: ${isRoute ? 'none' : `0 0 8px ${config.color}`}; border: ${markerStyle.border}; box-sizing: content-box; display: flex; justify-content: center; align-items: center; color: #fff; border-radius: 50%; cursor: pointer; padding: 2px;">
- <span style="transform: scale(0.8); font-weight: bold; font-size: 12px;">${displayText}</span>
- </div>
- `;
- }
- const marker = new this.AMap.Marker({
- position: [lng, lat],
- zIndex: markerStyle.zIndex,
- content: markerContent,
- offset: new this.AMap.Pixel(...markerStyle.offset),
- extData: {
- ...config,
- position: [lng, lat],
- statusColor: config.color || '#999',
- statusLabel: config.name,
- road: config.road || '规划路口',
- timestamp: Date.now(),
- time: this.formatEventTime(Date.now())
- }
- });
- marker.on('click', (e) => {
- if (this.isComponentDestroyed) return;
- const extData = e.target.getExtData();
- if (this.$route && this.$route.path === '/home') {
- this.cancelCloseInfoWindow();
- this.openLightInfo(extData, e.lnglat);
- }
- // 获取像素坐标
- const pixel = this.map.lngLatToContainer(e.lnglat);
- this.$emit('map-crossing-click', extData, e.lnglat, pixel);
- });
- marker.on('mouseover', (e) => {
- if (this.isComponentDestroyed) return;
- if (this.$route && this.$route.path === '/home') {
- this.cancelCloseInfoWindow();
- this.openLightInfo(e.target.getExtData(), e.lnglat);
- }
- // 获取像素坐标
- const pixel = this.map.lngLatToContainer(e.lnglat);
- // 传递路口鼠标滑入事件
- this.$emit('map-crossing-mouseover', e.target.getExtData(), e.lnglat, pixel);
- });
- marker.on('mouseout', (e) => {
- if (this.isComponentDestroyed) return;
- if (this.$route && this.$route.path === '/home') {
- this.scheduleCloseInfoWindow();
- }
- // 传递路口鼠标滑出事件
- this.$emit('map-crossing-mouseout', e.target.getExtData());
- });
- return marker;
- } catch (e) {
- console.warn('创建标记时出错:', e);
- return null;
- }
- },
- openLightInfo(data, position) {
- if (!this.isMapReady()) return;
- const infoWindowId = `info-window-${Date.now()}`;
- this.activeInfoWindowId = infoWindowId;
- const isAbnormal = ["离线", "降级", "故障"].includes(data.name);
- const deviceStatusText = isAbnormal ? data.name : '正常';
- const alarmInfoText = isAbnormal ? this.getAlarmInfoText(data.name) : '';
- const eventTimeText = this.formatEventTime(data.timestamp || data.time);
- let statusDotContent = '';
-
- if (isAbnormal) {
- const iconName = data.name === '离线' ? 'lixian' : data.name === '降级' ? 'jiangji' : 'guzhang';
- statusDotContent = `<img src="${require(`@/assets/images/icon_${iconName}.png`)}" style="width: 100%; height: 100%; object-fit: contain;" />`;
- } else {
- statusDotContent = `<span>${data.name.charAt(0)}</span>`;
- }
-
- const content = `
- <div class="custom-info-card" id="${infoWindowId}">
- <div class="close-btn" data-id="${infoWindowId}">✕</div>
- <div class="card-header">
- <div class="status-dot ${isAbnormal ? 'breathe' : ''}" style="background: ${isAbnormal ? 'transparent' : data.statusColor}; border: ${isAbnormal ? 'none' : ''}">
- ${statusDotContent}
- </div>
- <span class="status-text">${data.statusLabel}</span>
- </div>
- <div class="card-body">
- ${isAbnormal
- ? `
- <div class="info-line"><span class="label">路口名称:</span><span class="value">${data.road}</span></div>
- <div class="info-line"><span class="label">设备状态:</span><span class="value digital">${deviceStatusText}</span></div>
- <div class="info-line"><span class="label">报警信息:</span><span class="value">${alarmInfoText}</span></div>
- <div class="info-line"><span class="label">发生时间:</span><span class="value digital">${eventTimeText}</span></div>
- `
- : `
- <div class="info-line"><span class="label">路口名称:</span><span class="value">${data.road}</span></div>
- <div class="info-line"><span class="label">设备状态:</span><span class="value digital">${deviceStatusText}</span></div>
- `
- }
- </div>
- </div>
- `;
- if (!this.infoWindow) {
- this.infoWindow = new this.AMap.InfoWindow({
- isCustom: true,
- offset: new this.AMap.Pixel(0, -20),
- autoMove: false // 防止弹窗自动平移导致的中心点偏移
- });
- }
- this.infoWindow.setContent(content);
- this.infoWindow.open(this.map, position);
- setTimeout(() => {
- if (this.activeInfoWindowId !== infoWindowId) return;
- const closeBtn = document.querySelector(`#${infoWindowId} .close-btn`);
- if (closeBtn) {
- closeBtn.addEventListener('click', () => {
- if (this.infoWindow) this.infoWindow.close();
- });
- }
- const root = document.querySelector(`#${infoWindowId}`);
- if (root) {
- root.addEventListener('mouseenter', () => {
- if (this.activeInfoWindowId !== infoWindowId) return;
- this.isInfoWindowHovered = true;
- this.cancelCloseInfoWindow();
- });
- root.addEventListener('mouseleave', () => {
- if (this.activeInfoWindowId !== infoWindowId) return;
- this.isInfoWindowHovered = false;
- this.scheduleCloseInfoWindow();
- });
- }
- }, 100);
- },
- cancelCloseInfoWindow() {
- if (this.infoCloseTimer) {
- clearTimeout(this.infoCloseTimer);
- this.infoCloseTimer = null;
- }
- },
- scheduleCloseInfoWindow() {
- this.cancelCloseInfoWindow();
- this.infoCloseTimer = setTimeout(() => {
- if (this.isComponentDestroyed) return;
- if (this.isInfoWindowHovered) return;
- if (this.infoWindow) this.infoWindow.close();
- this.activeInfoWindowId = null;
- }, 160);
- },
- getAlarmInfoText(statusName) {
- if (statusName === '离线') return '通讯中断设备离线';
- if (statusName === '降级') return '降级定周期控制';
- if (statusName === '故障') return '东向左转信号灯红绿同亮';
- return '设备异常';
- },
- formatEventTime(input) {
- let d = null;
- if (input instanceof Date) d = input;
- else if (typeof input === 'number') d = new Date(input);
- else if (typeof input === 'string') {
- const t = Date.parse(input);
- if (!Number.isNaN(t)) d = new Date(t);
- }
- if (!d || Number.isNaN(d.getTime())) d = new Date();
- const y = d.getFullYear();
- const m = d.getMonth() + 1;
- const day = d.getDate();
- const hh = String(d.getHours()).padStart(2, '0');
- const mm = String(d.getMinutes()).padStart(2, '0');
- return `${y}.${m}.${day} ${hh}:${mm}`;
- },
- toggleAll() {
- const targetState = !this.isAllSelected;
- if (!this.isMapReady()) return;
- if (targetState) {
- this.activeLegends = this.statusConfig.map(item => item.name);
- Object.values(this.routeGroups).forEach(overlays => {
- if (overlays && overlays.length > 0) this.map.add(overlays);
- });
- } else {
- this.activeLegends = [];
- Object.values(this.routeGroups).forEach(overlays => {
- if (overlays && overlays.length > 0) this.map.remove(overlays);
- });
- if (this.infoWindow) this.infoWindow.close();
- }
- },
- toggleRouteVisible(name) {
- if (!this.isMapReady()) return;
- const overlays = this.routeGroups[name] || [];
- const index = this.activeLegends.indexOf(name);
- if (index > -1) {
- this.activeLegends.splice(index, 1);
- this.map.remove(overlays);
- if (this.infoWindow) this.infoWindow.close();
- } else {
- this.activeLegends.push(name);
- this.map.add(overlays);
- }
- },
- focusByLocation(targetPos) {
- if (!this.isMapReady() || !targetPos) return;
- // 如果是字符串坐标 "lng,lat",则解析
- let pos = targetPos;
- if (typeof targetPos === 'string') {
- pos = targetPos.split(',').map(Number);
- }
- if (!Array.isArray(pos) || pos.length < 2) return;
- const [targetLng, targetLat] = pos;
- let bestMarker = null;
- let minDistanceSq = Infinity;
- // 遍历所有路由组,寻找离坐标点最近的标记
- Object.values(this.routeGroups).forEach(group => {
- if (!Array.isArray(group)) return;
- group.forEach(item => {
- if (!(item instanceof this.AMap.Marker)) return;
- const markerExt = item.getExtData();
- const markerPos = markerExt.position;
- if (!markerPos) return;
- const dx = markerPos[0] - targetLng;
- const dy = markerPos[1] - targetLat;
- const distSq = dx * dx + dy * dy;
-
- // 容差范围内(约 20 米),寻找最接近的点
- if (distSq < 0.000001) {
- // 优先规则:如果距离相同或非常接近,优先选择异常状态点(离线/降级/故障)
- const isAbnormal = ["离线", "降级", "故障"].includes(markerExt.name);
- const currentIsAbnormal = bestMarker ? ["离线", "降级", "故障"].includes(bestMarker.getExtData().name) : false;
-
- if (distSq < minDistanceSq || (isAbnormal && !currentIsAbnormal)) {
- minDistanceSq = distSq;
- bestMarker = item;
- }
- }
- });
- });
- if (bestMarker) {
- const finalPos = bestMarker.getPosition();
- this.map.setZoomAndCenter(17, finalPos, false, 500);
- setTimeout(() => {
- if (!this.isComponentDestroyed) this.openLightInfo(bestMarker.getExtData(), finalPos);
- }, 600);
- } else {
- // 如果找不到对应的标记,直接使用传入的坐标设置地图中心
- this.map.setZoomAndCenter(17, [targetLng, targetLat], false, 500);
- }
- },
- toggleLegend() {
- this.legendVisible = !this.legendVisible;
- },
- // 按4:4:4比例提取故障、离线、降级路口信息并存储到localStorage
- storeStatusCoordsToLocalStorage() {
- const alarmTypes = [
- { status: "故障", titles: ["通讯中断", "灯组故障", "相位冲突", "绿冲突"], level: "high", type: "error" },
- { status: "离线", titles: ["信号机离线", "信号机离线", "通讯中断", "检测器异常"], level: "mid", type: "warning" },
- { status: "降级", titles: ["降级黄闪", "降级黄闪", "方案切换异常", "检测器异常"], level: "mid", type: "warning" },
- ];
- const alarmList = [];
- let id = 1;
- alarmTypes.forEach(({ status, titles, level, type }) => {
- (this.statusIntersections[status] || []).slice(0, 4).forEach((item, i) => {
- const lng = item["位置-经度"];
- const lat = item["位置-纬度"];
- const name = item["路口名称"] || "";
- if (!lng || !lat) return;
- alarmList.push({
- id: `A${String(id).padStart(3, "0")}`,
- title: titles[i] || titles[0],
- loc: name,
- level,
- type,
- description: `${name}-${titles[i] || titles[0]}`,
- position: [lng, lat],
- });
- // 保持原有的 pos1-pos12 存储,兼容其他可能的引用
- localStorage.setItem(`pos${id}`, `${lng},${lat}`);
- id++;
- });
- });
- localStorage.setItem("alarmListFromMap", JSON.stringify(alarmList));
- console.log('状态坐标及告警数据已存储到localStorage');
- },
- // 公开方法:将经纬度转换为像素坐标
- lngLatToPixel(lng, lat) {
- if (!this.map) return null;
- return this.map.lngLatToContainer([lng, lat]);
- }
- }
- };
- </script>
- <style scoped>
- .map-wrapper {
- width: 100%;
- height: 100vh;
- position: relative;
- background: #010813;
- }
- .map-container {
- width: 100%;
- height: 100%;
- }
- ::v-deep .amap-logo,
- ::v-deep .amap-copyright,
- ::v-deep .amap-copyright-logo {
- display: none !important;
- }
- ::v-deep .pure-light-node.breathe {
- animation: light-breathe 2s infinite ease-in-out;
- }
- ::v-deep .pure-light-node span {
- display: flex;
- transform: scale(0.75);
- align-items: center;
- }
- ::v-deep .pure-light-node:hover {
- transform: scale(1.4);
- filter: brightness(1.2);
- }
- @keyframes light-breathe {
- 0% {
- transform: scale(0.9);
- opacity: 0.8;
- }
- 50% {
- transform: scale(1.1);
- opacity: 1;
- }
- 100% {
- transform: scale(0.9);
- opacity: 0.8;
- }
- }
- ::v-deep .close-btn {
- position: absolute;
- top: 10px;
- right: 12px;
- color: #8da6c7;
- cursor: pointer;
- font-size: 16px;
- transition: color 0.3s;
- line-height: 1;
- z-index: 10;
- }
- ::v-deep .close-btn:hover {
- color: #ffffff;
- }
- ::v-deep .custom-info-card {
- position: relative;
- background: rgba(10, 15, 24, 0.95);
- border-radius: 10px;
- padding: 12px 16px;
- min-width: 200px;
- border: 1px solid rgba(255, 255, 255, 0.1);
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
- color: #fff;
- }
- ::v-deep .card-header {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- }
- ::v-deep .status-dot {
- width: 30px;
- height: 30px;
- border-radius: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- margin-right: 8px;
- font-size: 14px;
- padding: 0;
- box-sizing: border-box;
- }
- ::v-deep .status-dot.breathe {
- animation: light-breathe 2s infinite ease-in-out;
- }
- ::v-deep .status-dot span {
- transform: scale(0.75);
- }
- ::v-deep .status-dot img {
- width: 100%;
- height: 100%;
- object-fit: contain;
- display: block;
- }
- ::v-deep .status-text {
- font-size: 15px;
- font-weight: bold;
- }
- ::v-deep .info-line {
- display: flex;
- margin-bottom: 6px;
- font-size: 13px;
- align-items: center;
- }
- ::v-deep .label {
- color: #8da6c7;
- white-space: nowrap;
- }
- ::v-deep .value {
- color: #ffffff;
- }
- ::v-deep .digital {
- font-family: 'Consolas', monospace;
- }
- .map-legend {
- position: absolute;
- bottom: 30px;
- right: 40px;
- background: rgba(5, 22, 45, 0.9);
- border: 1px solid #1e4d8e;
- padding: 15px;
- border-radius: 6px;
- z-index: 100;
- transition: all 0.3s ease-in-out;
- opacity: 1;
- max-width: 200px;
- overflow: hidden;
- }
- .map-legend.legend-hidden {
- opacity: 0;
- transform: translateX(calc(100% + 20px));
- pointer-events: none;
- }
- .legend-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 12px;
- border-bottom: 1px solid #1e4d8e;
- padding-bottom: 8px;
- }
- .legend-close-btn {
- color: #8da6c7;
- cursor: pointer;
- font-size: 16px;
- transition: color 0.3s;
- line-height: 1;
- }
- .legend-close-btn:hover {
- color: #ffffff;
- }
- .legend-show-btn {
- position: absolute;
- bottom: 30px;
- right: 20px;
- background: rgba(5, 22, 45, 0.9);
- border: 1px solid #1e4d8e;
- width: 40px;
- height: 40px;
- border-radius: 6px 0 0 6px;
- display: flex;
- justify-content: center;
- align-items: center;
- cursor: pointer;
- z-index: 99;
- transition: all 0.3s ease-in-out;
- }
- .legend-show-btn:hover {
- background: rgba(10, 30, 60, 0.9);
- border-color: #3a75c4;
- }
- .legend-show-icon {
- color: #8da6c7;
- font-size: 18px;
- transition: color 0.3s;
- }
- .legend-show-btn:hover .legend-show-icon {
- color: #ffffff;
- }
- .legend-title {
- color: #fff;
- font-size: 14px;
- }
- .legend-item {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- cursor: pointer;
- transition: 0.3s;
- }
- .legend-item.is-inactive {
- opacity: 0.2;
- filter: grayscale(1);
- }
- .legend-dot {
- margin-right: 10px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .legend-dot:not(.is-status-wrapper) {
- width: 20px;
- height: 20px;
- border-radius: 50%;
- }
- .legend-dot span {
- display: inline-block;
- width: 20px;
- height: 20px;
- font-size: 12px;
- color: #FFF;
- text-align: center;
- transform: scale(0.75);
- line-height: 20px;
- }
- .legend-dot.special-route {
- position: relative;
- overflow: visible !important;
- z-index: 1;
- border: none !important;
- border-radius: 50%;
- }
- .legend-dot.special-route span {
- position: relative;
- z-index: 3;
- font-weight: bold;
- }
- .legend-dot.special-route::after {
- content: "";
- position: absolute;
- top: 50%;
- left: 50%;
- width: 150%;
- height: 3px;
- background-color: inherit;
- opacity: 0.8;
- transform: translate(-50%, -50%) rotate(-45deg);
- pointer-events: none;
- z-index: 0;
- }
- .legend-dot.special-route::before {
- content: "";
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- border-radius: 50%;
- z-index: 2;
- background-color: inherit;
- opacity: 1;
- }
- .legend-label {
- flex: 1;
- color: #d0d9e2;
- font-size: 13px;
- }
- .legend-status {
- font-size: 11px;
- color: #5b7da8;
- }
- .all-select {
- border-bottom: 1px solid rgba(255, 255, 255, 0.2);
- padding-bottom: 12px;
- margin-bottom: 12px !important;
- }
- .all-select .legend-dot {
- border-radius: 2px;
- transition: all 0.3s;
- width: 10px;
- height: 10px;
- }
- .legend-dot.is-status-wrapper {
- width: 28px;
- height: 28px;
- background-color: transparent !important;
- box-shadow: none !important;
- border: none !important;
- margin-right: 0;
- transform: translateX(-15%);
- }
- .status-icon {
- width: 100%;
- height: 100%;
- object-fit: contain;
- display: block;
- }
- ::v-deep .pure-light-node {
- width: 16px;
- height: 16px;
- border-radius: 50%;
- border: 2px solid rgba(255, 255, 255, 0.8);
- cursor: pointer;
- transition: all 0.3s;
- display: flex;
- justify-content: center;
- align-items: center;
- color: #fff;
- pointer-events: auto;
- }
- ::v-deep .pure-light-node.route-node {
- position: relative;
- overflow: visible;
- }
- ::v-deep .pure-light-node.route-node::after {
- content: "";
- position: absolute;
- top: 50%;
- left: 50%;
- width: 150%;
- height: 3px;
- background-color: inherit;
- opacity: 0.8;
- transform: translate(-50%, -50%) rotate(-45deg);
- pointer-events: none;
- }
- ::v-deep .pure-light-node.route-node span {
- position: relative;
- z-index: 1;
- }
- /* 异常状态增加稍微剧烈一点的呼吸感,但缩小范围 */
- @keyframes light-breathe {
- 0% {
- transform: scale(0.9);
- opacity: 0.8;
- }
- 50% {
- transform: scale(1.1);
- opacity: 1;
- }
- 100% {
- transform: scale(0.9);
- opacity: 0.8;
- }
- }
- /* 首页展示时,如果觉得还是太密,可以给非异常节点降权 */
- ::v-deep .pure-light-node:not(.abnormal-node) {
- border: 1px solid rgba(255, 255, 255, 0.4);
- }
- </style>
|