<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Antv L7 + mapbox 实现3D地图</title>
<style>
html,body{overflow:hidden;margin:0;}
#idMap { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="idMap">
</div>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.js'></script>
<!-- <link href='https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.css' rel='stylesheet' /> -->
<script src = 'https://unpkg.com/@antv/l7'></script>
<script>
//mapboxgl.accessToken = 'pk.------------------你的mapboxtoken';
const scene = new L7.Scene({
id: 'idMap',
map: new L7.Mapbox({
style: 'dark',
center: [ 110.497005, 38.835641 ],
pitch: 20,
zoom: 3.8,
})
});
scene.on('loaded', () => {
let lineDown,lineUp,textLayer;
fetch('https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json')
.then(res => res.json())
.then(data => {
const texts = [];
data.features.map(option => {
const { name, center } = option.properties;
const [ lng, lat ] = center || [];
texts.push({ name, lng, lat });
return '';
});
// textLayer = new L7.PointLayer({ zIndex: 2 })
// .source(texts, {
// parser: {
// type: 'json',
// x: 'lng',
// y: 'lat'
// }
// })
// .shape('name', 'text')
// .size(14)
// .color('#0ff')
// .style({
// textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
// spacing: 1, // 字符间距
// padding: [ 1, 1 ], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
// stroke: '#0ff', // 描边颜色
// strokeWidth: 0.2, // 描边宽度
// raisingHeight: 800000,
// textAllowOverlap: true
// });
// scene.addLayer(textLayer);
lineUp = new L7.LineLayer({ zIndex: 1 })
.source(data)
.shape('line')
.color('#0DCCFF')
.size(1)
.style({
raisingHeight: 800000
});
scene.addLayer(lineUp);
const provincelayer = new L7.PolygonLayer({})
.source(data)
.size(800000) // 切面高度
.shape('extrude')
.color('#0DCCFF')
.active({
color: 'rgb(100,230,255)'
})
.style({
heightfixed: true,
pickLight: true,
raisingHeight: 0, // 抬升高度,距离底图的高度
opacity: 0.8
});
scene.addLayer(provincelayer);
return '';
});
return '';
});
</script>
</body>
</html>
Antv L7 + mapbox 实现简单地图场景
需积分: 3 103 浏览量
2023-07-18
17:20:07
上传
评论
收藏 15KB ZIP 举报
zlzhaoe
- 粉丝: 60
- 资源: 26
最新资源
- 5uonly.apk
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- 基于JSP毕业设计-基于WEB操作系统课程教学网站的设计与实现(源代码+论文).zip
- 基于LM324和LM386的音响放大器Multisim仿真+PCB电路原理图
- Python机器学习与数据挖掘环境配置与库验证
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈