echarts中geo不同区域用不同颜色

地图着色的方法在网上找了好久,开始用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: [      //对不同的区块进行着色
            {
              name: '马山县', //区块名称
              itemStyle: {
                  normal: {
                      areaColor: '#fbd8f3'
                  }
              }
            },{
              name: '上林县',
              itemStyle: {
                  normal: {
                      areaColor: '#fcc8b8'
                  }
              }
          },{
            name: '宾阳县',
            itemStyle: {
                normal: {
                    areaColor: '#2b97df'
                }
            }
        }]
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容