共计 730 个字符,预计需要花费 2 分钟才能阅读完成。
let data = {features: [],
type: 'FeatureCollection'
}
area.forEach((item, index) => {// console.log(item)
let color = ''if (item.attrMap[' 业主方 '] ==='1111') {color = 'blue'} else if (item.attrMap['业主方'] === '2222') {color = 'red'} else if (item.attrMap['业主方'] === '3333') {color = '#00ff8a'} else if (item.attrMap['业主方'] === '4444') {color = '#855CA4'} else {color = '#855'}
data.features.push({
geometry: {coordinates: [item.pointsArr],
type: 'Polygon'
},
properties: {
description: item.description ? item.description : '',
markerLatLng: item.pointsArr[0],
color:color
},
id: index,
type: 'Feature'
})
})
let layer = new PolygonLayer({zIndex: 2})
.source(data)
.color('color',(type)=>{return type})
.shape('fill')
.active(true)
.style({opacity: 0.35})
properties 中绑定参数,在办法回调 color 中指定参数名 能够获取到, 多个参数应用 * 拼接 ‘color * description’
正文完