angular15怎么引入中国地图?

作者站长头像
站长
· 阅读数 17

看了现在的echarts好像没有地图了,现在下载了一个china.json该怎么用

回复
1个回答
avatar
test
2024-06-26

Vue举例, 其实配置都差不多:

import echarts from "echarts"
      // echart 配制option  
      option: {
        tooltip: {
          show: true,
          // triggerOn: 'mousemove',   // mousemove、click
          padding: 8,
          borderWidth: 1,
          borderColor: '#1051B5',
          backgroundColor: '#F8FBFD',
          textStyle: {
            color: '#000000',
            fontSize: 13
          }
        },
        // 分段统计
        visualMap: {
          show: true,
          left: 'auto',
          right: 'auto',
          top: 'auto',
          align: 'auto',
          itemWidth: 12,
          itemHeight: 12,
          itemGap: 12,
          showLabel: true,
          orient: 'horizontal',
          inverse: true,
          pieces: [
            {
              gt: 500,
              label: '>500',
              color: '#BE2E2C'
            },
            {
              gte: 301,
              lte: 500,
              label: '301-500',
              color: '#EC5B56'
            },
            {
              gte: 101,
              lte: 300,
              label: '101-300',
              color: '#3853E2'
            },
            {
              lte: 100,
              label: '<=100',
              color: '#8BA4F8'
            }
          ]
        },
        geo: {
          map: 'china',
          scaleLimit: {
            min: 0,
            max: 2
          },
          zoom: 1,
          // roam: true,
          top: 'auto',
          left: 'auto',
          // layoutCenter: ['0%', '10%'],
          // 如果宽高比大于 1 则宽度为 100,如果小于 1 则高度为 100,保证了不超过 100x100 的区域
          // layoutSize: 300,
          // 是否显示城市名
          // label: {
          //   normal: {
          //     show: true,
          //     fontSize: 14,
          //     color: 'rgba(0,0,0,0.7)'
          //   }
          // },
          itemStyle: {
            normal: {
              // shadowBlur: 50,
              // shadowColor: 'rgba(0, 0, 0, 0.2)',
              borderColor: '#BFBFBF',
              borderWidth: 1,
              areaColor: '#EBEBEB'
            },
            // 移入背景色
            emphasis: {
              areaColor: '#B8CFF2',
              shadowOffsetX: 0,
              shadowOffsetY: 0,
              borderWidth: 0
            }
          }
        },
        series: [
          {
            name: '上市公司',
            type: 'map',
            geoIndex: 0,
            data: [],
          }
        ]
      }
// 第一个参数与gio.map要一致
echarts.registerMap('china', 地图JSON数据))
回复
likes
适合作为回答的
  • 经过验证的有效解决办法
  • 自己的经验指引,对解决问题有帮助
  • 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
  • 询问内容细节或回复楼层
  • 与题目无关的内容
  • “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容