当前位置:网站首页>mapbox-gl开发教程(十二):加载面图层数据
mapbox-gl开发教程(十二):加载面图层数据
2022-06-29 20:00:00 【地理信息技术杂谈】
–mapbox-gl是一个开源、基于webgl技术的前端地图类库–
在地图应用的开发中,加载面数据,显示区域、范围等信息,在mapbox-gl对应的是面(fill)图层,下边讲一下如何在mapbox-gl加载线图层数据。
mapbox-gl加载矢量数据,通过两种数据源,一种是矢量切片(vector),另一种是geojson数据,数据源加载完成后,再进行图层的设置。
以geojson数据为例:
//添加geojson数据源,id为maine
map.addSource('maine', {
'type': 'geojson',
'data': {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [
[
[137.13734, 45.13745],
[136.96466, 44.8097],
[138.03252, 44.3252],
[139.06, 43.98],
[130.11617, 43.68405],
[130.64573, 43.09008],
[130.75102, 43.08003],
[130.79761, 43.21973],
[130.98176, 43.36789],
[130.94416, 43.46633],
[131.08482, 45.30524],
[130.66002, 45.46022],
[130.30495, 45.91479],
[130.00014, 46.69317],
[139.23708, 47.44777],
[138.90478, 47.18479],
[138.2343, 47.35462],
[137.79035, 47.06624],
[137.79141, 45.70258],
[137.13734, 45.13745]
]
]
}
}
});
// 添加面图层,使用maine的数据源
map.addLayer({
'id': 'maine',
'type': 'fill',
'source': 'maine',
'layout': {
},
'paint': {
//填充颜色
'fill-color': '#0080ff',
//透明度设置
'fill-opacity': 0.5
}
});
面图层颜色设置,对应参数可以使用rgba形式:
“fill-color”: “rgba(32, 62, 122, 1)”
最后的参数1同样是设置透明度,优先级要比fill-opacity低。
面图层属性设置链接:
https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill
mapbox-gl开发是讲述如何从基础到实际应用进行地图开发的教程,不定时进行持续进行更新,如有疑问,公众号留言进行讨论。
mapbox-gl官网地址:https://docs.mapbox.com/mapbox-gl-js/guides/
边栏推荐
- Deficiencies and optimization schemes in Dao
- Tiger painter mengxiangshun's digital collection is on sale in limited quantities and comes with Maotai in the year of the tiger
- 【网络方向实训】-企业园区网络设计-【Had Done】
- Regular expression series of mobile phone numbers
- Flume-ng配置
- 【U盘检测】为了转移压箱底的资料,买了个2T U盘检测仅仅只有47G~
- 1404萬!四川省人社廳關系型數據庫及中間件軟件系統昇級采購招標!
- JVM(4) 字節碼技術+運行期優化
- Sword finger offer 66 Building a product array
- Detailed description of gaussdb (DWS) complex and diverse resource load management methods
猜你喜欢
File contains vulnerability
【网络方向实训】-企业园区网络设计-【Had Done】
Flutter calls Baidu map app to realize location search and route planning
Canonical engineers are trying to solve the performance problem of Firefox snap
MySQL remote connection
idea中方法上没有小绿色三角
Flume theory
童年经典蓝精灵之百变蓝爸爸数字藏品中奖名单公布
There are more than 20 databases in a MySQL with 3306 ports. How can I backup more than 20 databases with one click and do system backup to prevent data from being deleted by mistake?
How to set a pod to run on a specified node
随机推荐
Nacos problem
Static static member variables use @value injection
【剑指Offer】51. 数组中的逆序对
JVM (2) garbage collection
Talk about the delta configuration of Eureka
Union find
剑指 Offer 59 - II. 队列的最大值
Lock4j -- distributed lock Middleware -- customize the logic of lock acquisition failure
苹果iPhone手机升级系统内存空间变小不够如何解决?
Zotero期刊自动匹配更新影响因子
Regular expression series of mobile phone numbers
Flume configuration 4 - Custom source+sink
2022年深圳市福田区支持招商引资若干政策
Dynamics crm: among locally deployed servers, sandbox, unzip, VSS, asynchronous and monitor services
Flume configuration 3 - interceptor filtering
Performance improvement at the cost of other components is not good
JMeter BeanShell explanation and thread calling
社区访谈丨一个IT新人眼中的JumpServer开源堡垒机
一次 Keepalived 高可用的事故,让我重学了一遍它!
Is it safe to open a new bond Online