Appearance
面
根据面数据,绘制面并填充颜色
示例
一. 添加数据源
javascript
// 添加数据源第一个参数为数据源id,这里使用标准的GeoJSON格式
map.addSource('maine', {
'type': 'geojson',
'data': {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [
[
[114.138947, 22.373061],
[114.128947, 22.363061],
[114.122947, 22.370061],
[114.129947, 22.355061],
]
]
}
}
});二. 添加图层
javascript
map.addLayer({
'id': 'maine',// 图层id
'type': 'fill',// 渲染方式
'source': 'maine',// 绑定数据源id
'layout': {},
'paint': {
'fill-color': '#ff0000',// 填充颜色
'fill-opacity': 0.4,// 填充透明度
}
});