<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>基站地图分布可视化</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
background-color: #f5f5f5;
}
#map {
height: 100vh;
width: 100%;
}
.stats-panel {
position: absolute;
top: 20px;
right: 20px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
padding: 20px;
min-width: 280px;
z-index: 1000;
}
.stats-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 15px;
color: #333;
}
.stats-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.stats-item:last-child {
border-bottom: none;
}
.stats-label {
display: flex;
align-items: center;
gap: 8px;
}
.stats-color {
width: 16px;
height: 16px;
border-radius: 50%;
}
.stats-count {
font-weight: bold;
font-size: 16px;
}
.legend {
position: absolute;
bottom: 20px;
left: 20px;
background: white;
padding: 15px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
z-index: 1000;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
}
.legend-item:last-child {
margin-bottom: 0;
}
.legend-color {
width: 20px;
height: 20px;
border-radius: 50%;
}
.popup-content {
padding: 5px;
}
.popup-title {
font-weight: bold;
margin-bottom: 5px;
}
.popup-info {
font-size: 14px;
color: #666;
}
.status-badge {
display: inline-block;
padding: 2px 8px;
border-radius: 12px;
font-size: 12px;
color: white;
margin-top: 5px;
}
</style>
</head>
<body>
<div id="map"></div>
<div class="stats-panel">
<div class="stats-title">基站状态统计</div>
<div class="stats-item">
<div class="stats-label">
<div class="stats-color" style="background-color: #52c41a;"></div>
<span>正常站点</span>
</div>
<div class="stats-count" id="normal-count">0</div>
</div>
<div class="stats-item">
<div class="stats-label">
<div class="stats-color" style="background-color: #faad14;"></div>
<span>故障站点</span>
</div>
<div class="stats-count" id="fault-count">0</div>
</div>
<div class="stats-item">
<div class="stats-label">
<div class="stats-color" style="background-color: #f5222d;"></div>
<span>断站</span>
</div>
<div class="stats-count" id="offline-count">0</div>
</div>
<div class="stats-item">
<div class="stats-label">
<div class="stats-color" style="background-color: #722ed1;"></div>
<span>退服小区</span>
</div>
<div class="stats-count" id="retired-count">0</div>
</div>
</div>
<div class="legend">
<div class="legend-item">
<div class="legend-color" style="background-color: #52c41a;"></div>
<span>正常站点</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background-color: #faad14;"></div>
<span>故障站点</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background-color: #f5222d;"></div>
<span>断站</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background-color: #722ed1;"></div>
<span>退服小区</span>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
// 初始化地图
const map = L.map('map').setView([39.9042, 116.4074], 11);
// 添加地图图层
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
// 模拟基站数据
const baseStations = [
// 正常站点
{ id: 1, name: "基站-001", lat: 39.9042, lng: 116.4074, status: "normal", type: "宏站", operator: "中国移动" },
{ id: 2, name: "基站-002", lat: 39.9142, lng: 116.4174, status: "normal", type: "微站", operator: "中国联通" },
{ id: 3, name: "基站-003", lat: 39.8942, lng: 116.3974, status: "normal", type: "宏站", operator: "中国电信" },
{ id: 4, name: "基站-004", lat: 39.9242, lng: 116.4274, status: "normal", type: "微站", operator: "中国移动" },
{ id: 5, name: "基站-005", lat: 39.8842, lng: 116.3874, status: "normal", type: "宏站", operator: "中国联通" },
// 故障站点
{ id: 6, name: "基站-006", lat: 39.9092, lng: 116.4124, status: "fault", type: "宏站", operator: "中国移动" },
{ id: 7, name: "基站-007", lat: 39.9192, lng: 116.4224, status: "fault", type: "微站", operator: "中国电信" },
{ id: 8, name: "基站-008", lat: 39.8992, lng: 116.4024, status: "fault", type: "宏站", operator: "中国联通" },
// 断站
{ id: 9, name: "基站-009", lat: 39.9292, lng: 116.4324, status: "offline", type: "微站", operator: "中国移动" },
{ id: 10, name: "基站-010", lat: 39.8892, lng: 116.3924, status: "offline", type: "宏站", operator: "中国电信" },
{ id: 11, name: "基站-011", lat: 39.9342, lng: 116.4374, status: "offline", type: "微站", operator: "中国联通" },
// 退服小区
{ id: 12, name: "基站-012", lat: 39.9142, lng: 116.4024, status: "retired", type: "宏站", operator: "中国移动" },
{ id: 13, name: "基站-013", lat: 39.8942, lng: 116.4124, status: "retired", type: "微站", operator: "中国电信" },
{ id: 14, name: "基站-014", lat: 39.9242, lng: 116.3974, status: "retired", type: "宏站", operator: "中国联通" },
{ id: 15, name: "基站-015", lat: 39.8842, lng: 116.4224, status: "retired", type: "微站", operator: "中国移动" }
];
// 状态对应的颜色
const statusColors = {
normal: '#52c41a',
fault: '#faad14',
offline: '#f5222d',
retired: '#722ed1'
};
// 状态对应的中文名称
const statusNames = {
normal: '正常',
fault: '故障',
offline: '断站',
retired: '退服'
};
// 创建标记并添加到地图
const markers = [];
baseStations.forEach(station => {
const marker = L.circleMarker([station.lat, station.lng], {
radius: 8,
fillColor: statusColors[station.status],
color: '#fff',
weight: 2,
opacity: 1,
fillOpacity: 0.8
}).addTo(map);
// 添加弹出窗口
const popupContent = `
<div class="popup-content">
<div class="popup-title">${station.name}</div>
<div class="popup-info">
<div>类型:${station.type}</div>
<div>运营商:${station.operator}</div>
<div>
<span class="status-badge" style="background-color: ${statusColors[station.status]}">
${statusNames[station.status]}
</span>
</div>
</div>
</div>
`;
marker.bindPopup(popupContent);
markers.push(marker);
});
// 更新统计面板
function updateStats() {
const stats = {
normal: baseStations.filter(s => s.status === 'normal').length,
fault: baseStations.filter(s => s.status === 'fault').length,
offline: baseStations.filter(s => s.status === 'offline').length,
retired: baseStations.filter(s => s.status === 'retired').length
};
document.getElementById('normal-count').textContent = stats.normal;
document.getElementById('fault-count').textContent = stats.fault;
document.getElementById('offline-count').textContent = stats.offline;
document.getElementById('retired-count').textContent = stats.retired;
}
// 初始化统计
updateStats();
// 添加缩放动画效果
markers.forEach((marker, index) => {
setTimeout(() => {
marker.setStyle({
radius: 12
});
setTimeout(() => {
marker.setStyle({
radius: 8
});
}, 300);
}, index * 50);
});
</script>
</body>
</html>