删除第一张风险监控地图(SecurityRiskMap)及相关代码

This commit is contained in:
gcw_yTjNWok9
2025-12-18 13:37:44 +08:00
parent bb17c69ba9
commit 7e6321a7b9
11 changed files with 2084 additions and 89 deletions

268
src/utils/mapLoader.js Normal file
View File

@@ -0,0 +1,268 @@
/**
* 地图数据加载工具
* 统一管理世界地图和中国地图数据的导入
*/
import * as echarts from 'echarts'
/**
* 加载世界地图数据
* @returns {Promise<boolean>} 是否加载成功
*/
export const loadWorldMap = async () => {
try {
// 第一优先从根目录加载原始世界地图数据ECharts压缩格式
await import('/world.js')
// world.js 文件会自动注册地图,无需手动处理
console.log('World map loaded from root world.js file (ECharts compressed format)')
return true
} catch (error) {
console.warn('Failed to load world map from root world.js file:', error)
}
try {
// 第三优先从CDN加载真实的世界地图数据完整的国家轮廓
const response = await fetch('https://geo.datav.aliyun.com/areas_v3/bound/world.json')
if (response.ok) {
const worldGeoJSON = await response.json()
echarts.registerMap('world', worldGeoJSON)
console.log('World map loaded from CDN with real country boundaries')
return true
}
} catch (error) {
console.warn('Failed to load world map from CDN:', error)
}
// 最后的备用方案:使用简化的手动地图数据(仅作为最后选择)
console.warn('Using fallback world map data - this will show simplified rectangles')
const fallbackWorldGeoJSON = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": { "name": "China" },
"geometry": {
"type": "Polygon",
"coordinates": [[[73.5, 53.5], [134.8, 53.5], [134.8, 18.2], [73.5, 18.2], [73.5, 53.5]]]
}
},
{
"type": "Feature",
"properties": { "name": "United States" },
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[[[-158.2, 21.8], [-154.8, 21.8], [-154.8, 22.2], [-158.2, 22.2], [-158.2, 21.8]]],
[[[-178.3, 18.9], [-154.8, 18.9], [-154.8, 28.4], [-178.3, 28.4], [-178.3, 18.9]]],
[[[-171.8, 63.8], [-129.9, 63.8], [-129.9, 71.4], [-171.8, 71.4], [-171.8, 63.8]]],
[[[-125.0, 32.5], [-66.9, 32.5], [-66.9, 49.4], [-125.0, 49.4], [-125.0, 32.5]]]
]
}
},
{
"type": "Feature",
"properties": { "name": "Russia" },
"geometry": {
"type": "Polygon",
"coordinates": [[[19.6, 41.2], [180.0, 41.2], [180.0, 81.9], [19.6, 81.9], [19.6, 41.2]]]
}
},
{
"type": "Feature",
"properties": { "name": "Brazil" },
"geometry": {
"type": "Polygon",
"coordinates": [[[-73.9, -33.7], [-34.8, -33.7], [-34.8, 5.3], [-73.9, 5.3], [-73.9, -33.7]]]
}
},
{
"type": "Feature",
"properties": { "name": "Germany" },
"geometry": {
"type": "Polygon",
"coordinates": [[[5.9, 47.3], [15.0, 47.3], [15.0, 55.1], [5.9, 55.1], [5.9, 47.3]]]
}
},
{
"type": "Feature",
"properties": { "name": "India" },
"geometry": {
"type": "Polygon",
"coordinates": [[[68.2, 6.8], [97.4, 6.8], [97.4, 37.1], [68.2, 37.1], [68.2, 6.8]]]
}
},
{
"type": "Feature",
"properties": { "name": "Australia" },
"geometry": {
"type": "Polygon",
"coordinates": [[[113.3, -43.6], [153.6, -43.6], [153.6, -10.7], [113.3, -10.7], [113.3, -43.6]]]
}
},
{
"type": "Feature",
"properties": { "name": "Japan" },
"geometry": {
"type": "Polygon",
"coordinates": [[[129.4, 31.0], [145.8, 31.0], [145.8, 45.6], [129.4, 45.6], [129.4, 31.0]]]
}
},
{
"type": "Feature",
"properties": { "name": "United Kingdom" },
"geometry": {
"type": "Polygon",
"coordinates": [[[-8.6, 49.9], [1.8, 49.9], [1.8, 60.8], [-8.6, 60.8], [-8.6, 49.9]]]
}
},
{
"type": "Feature",
"properties": { "name": "France" },
"geometry": {
"type": "Polygon",
"coordinates": [[[-5.1, 41.3], [9.6, 41.3], [9.6, 51.1], [-5.1, 51.1], [-5.1, 41.3]]]
}
}
]
}
echarts.registerMap('world', fallbackWorldGeoJSON)
return true
}
/**
* 加载中国地图数据
* @returns {Promise<boolean>} 是否加载成功
*/
export const loadChinaMap = async () => {
try {
// 优先动态导入本地中国地图数据
await import('/china.js')
// china.js 文件会自动注册地图,无需手动处理
console.log('China map loaded from local file')
return true
} catch (error) {
console.warn('Failed to load china map from local file:', error)
}
try {
// 备用方案从CDN加载中国地图数据
const response = await fetch('https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json')
if (response.ok) {
const chinaGeoJSON = await response.json()
echarts.registerMap('china', chinaGeoJSON)
console.log('China map loaded from CDN')
return true
}
} catch (error) {
console.warn('Failed to load china map from CDN:', error)
}
// 最后的备用方案:使用简化的手动地图数据
console.warn('Using fallback china map data')
const fallbackChinaGeoJSON = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": { "name": "北京" },
"geometry": {
"type": "Polygon",
"coordinates": [[[115.4, 39.4], [117.5, 39.4], [117.5, 41.1], [115.4, 41.1], [115.4, 39.4]]]
}
},
{
"type": "Feature",
"properties": { "name": "上海" },
"geometry": {
"type": "Polygon",
"coordinates": [[[120.9, 30.7], [122.2, 30.7], [122.2, 31.9], [120.9, 31.9], [120.9, 30.7]]]
}
},
{
"type": "Feature",
"properties": { "name": "广东" },
"geometry": {
"type": "Polygon",
"coordinates": [[[109.7, 20.2], [117.2, 20.2], [117.2, 25.5], [109.7, 25.5], [109.7, 20.2]]]
}
},
{
"type": "Feature",
"properties": { "name": "浙江" },
"geometry": {
"type": "Polygon",
"coordinates": [[[118.0, 27.1], [123.2, 27.1], [123.2, 31.2], [118.0, 31.2], [118.0, 27.1]]]
}
},
{
"type": "Feature",
"properties": { "name": "江苏" },
"geometry": {
"type": "Polygon",
"coordinates": [[[116.4, 30.8], [121.9, 30.8], [121.9, 35.3], [116.4, 35.3], [116.4, 30.8]]]
}
},
{
"type": "Feature",
"properties": { "name": "山东" },
"geometry": {
"type": "Polygon",
"coordinates": [[[114.8, 34.4], [122.7, 34.4], [122.7, 38.4], [114.8, 38.4], [114.8, 34.4]]]
}
},
{
"type": "Feature",
"properties": { "name": "四川" },
"geometry": {
"type": "Polygon",
"coordinates": [[[97.3, 26.0], [108.5, 26.0], [108.5, 34.3], [97.3, 34.3], [97.3, 26.0]]]
}
}
]
}
echarts.registerMap('china', fallbackChinaGeoJSON)
return true
}
/**
* 预加载所有地图数据
* @returns {Promise<{world: boolean, china: boolean}>} 加载结果
*/
export const preloadAllMaps = async () => {
const results = await Promise.allSettled([
loadWorldMap(),
loadChinaMap()
])
return {
world: results[0].status === 'fulfilled' ? results[0].value : false,
china: results[1].status === 'fulfilled' ? results[1].value : false
}
}
/**
* 检查地图是否已注册
* @param {string} mapName - 地图名称 ('world' 或 'china')
* @returns {boolean} 是否已注册
*/
export const isMapRegistered = (mapName) => {
try {
// 尝试获取地图数据来检查是否已注册
const mapData = echarts.getMap(mapName)
return !!mapData
} catch (error) {
return false
}
}
/**
* 获取地图加载状态
* @returns {{world: boolean, china: boolean}} 地图注册状态
*/
export const getMapStatus = () => {
return {
world: isMapRegistered('world'),
china: isMapRegistered('china')
}
}