<style lang="scss" scoped>
.o-echarts {
  margin-top: 150px;
  min-width: 30px;
  min-height: 30px;
  width: 100%;
  height: 80%;
}
</style>
<template>
  <div id="echarts_map" class="o-echarts"></div>
</template>

<script>
import fjJson from "./map/quanzhou.json";

export default {
  name: "echart-map",
  data() {
    return {
      echartObj: null,
      option: {
        // tooltip: {
        //   trigger: "item",
        //   formatter: "{b}<br/>{c} (p / km2)",
        // },
        toolbox: {
          show: false,
          orient: "vertical",
          left: "right",
          top: "center",
          feature: {
            dataView: { readOnly: false },
            restore: {},
            saveAsImage: {},
          },
        },
        geo: {
          show: true,
          map: "泉州",
          lable: {
            color: "white",
            normal: {
              show: false,
            },
            emphasis: {
              show: false,
            },
          },

          itemStyle: {
            normal: {
              //阴影
              areaColor: "#7dc1d5",
              borderWidth: 0,
              borderColor: "#0395fc",
              shadowColor: "#0395fc",
              shadowBlur: 0,
              opacity: 0.8,
              // shadowOffsetX: 0,
              // shadowOffsetY: 0,
            },
          },
        },
        series: [
          {
            name: "泉州",
            type: "map",
            map: "泉州",
            zoom: 1,
            label: {
              show: true,
              color: "#fff",
            },
            itemStyle: {
              normal: {
                color: "#fff",
                borderWidth: 2, //边际线大小
                borderColor: "#a9f7fb", //边界线颜色
                areaColor: "#62b1cc", //默认区域颜色
              },
              emphasis: {
                show: true,
                color: "#fff",
                areaColor: "#a2ebee", //鼠标滑过区域颜色
                label: {
                  show: true,
                  textStyle: {
                    color: "#fff",
                  },
                },
              },
            },
            data: [],
          },
        ],
      },
    };
  },
  mounted() {
    this.echartObj = this.$echarts.init(document.getElementById("echarts_map"));
    this.$echarts.registerMap("泉州", fjJson);
    this.echartObj.setOption(this.option);
    window.addEventListener("resize", () => {
      if (this.echartObj && this.echartObj.resize) {
        this.echartObj.resize();
      }
    });
  },
  methods: {},
};
</script>
