实现功能为移入黄坦这个地点后对应行政区域高亮,这里我们后端在黄坦坐标给了字段region_id,为一个数组,我们需要根据这个region_id在行政区域切片中过滤对应的fid,从而实现高亮(说白了主要运用filter)
添加好source后:
let areaOption = {
id: `Aregion-layer`,
source: 'Aregion',
"source-layer": 'region'
}
areaOption = {
...areaOption,
type: 'fill',
layout: {},
filter: false,
paint: {
'fill-color': 'rgba(0,255,245,0.2)',
}
}
Amap.mapbox.addLayer(areaOption)
我们需要添加图层,并且将filter设置成false。
鼠标移入事件: