地圖著色的方法在網(wǎng)上找了好久蓬戚,開始用visualmap著色,后來要定位坐標椰苟,只能用geo抑月,找了好久,分享一下舆蝴!
需要在geo中添加regions屬性谦絮,詳見代碼
geo: {
map: 'nanning',
height: '100%',
width: '85%',
center: [108.46, 23.13],
zoom: 1,
label: {
show: true,
color: '#20fdfa',
emphasis: {
show: true,
color: '#fff'
}
},
roam: false,
itemStyle: {
normal: {
areaColor: '#323c4800', //地圖顏色
borderColor: '#0258b6',
borderWidth: 1
},
// emphasis: {
// areaColor: '#2a333d'
// }
},
regions: [ //對不同的區(qū)塊進行著色
{
name: '馬山縣', //區(qū)塊名稱
itemStyle: {
normal: {
areaColor: '#fbd8f3'
}
}
},{
name: '上林縣',
itemStyle: {
normal: {
areaColor: '#fcc8b8'
}
}
},{
name: '賓陽縣',
itemStyle: {
normal: {
areaColor: '#2b97df'
}
}
}]
}