地球仪大气层
为地球仪视图添加大气层效果;
<!DOCTYPE html>
<html lang="en">
<head>
<title>地球仪大气层</title>
<meta property="og:description" content="为地球仪视图添加大气层效果" />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://unpkg.com/maplibre-gl@5.5.0/dist/maplibre-gl.css' />
<script src='https://unpkg.com/maplibre-gl@5.5.0/dist/maplibre-gl.js'></script>
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const map = new maplibregl.Map({
container: 'map',
style: 'https://api.maptiler.com/maps/bright-v2/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL',
zoom: 0.5,
center: [0, 10],
projection: 'globe'
});
map.on('style.load', () => {
// 尝试不同的灯光颜色
// 设置灯光
map.setLight({
anchor: 'map',
color: '#fffdcc', // 暖黄色灯光
intensity: 1
});
// 设置大气层参数
map.setFog({
color: 'rgb(220, 237, 255)', // 淡蓝色,类似于天空
'high-color': 'rgb(36, 92, 223)', // 高处的深蓝色
'horizon-blend': 0.15, // 地平线混合
'space-color': 'rgb(11, 11, 25)', // 太空的颜色
'star-intensity': 0.8 // 星星的强度
});
});
</script>
</body>
</html>