eharts 中国地图添加城市(散点图实现,含获取城市坐标、图片转base64、自定义散点样式)

简介: eharts 中国地图添加城市(散点图实现,含获取城市坐标、图片转base64、自定义散点样式)

如上图所示,青岛不是省份、直辖市或特别行政区,所以默认的中国地图上,无法标注青岛,那本图是如何实现的呢?

实现思路

  1. 隐藏地图坐标默认的地名标签
        geo: {
          map: "china",
          label: {
            emphasis: {
              // 高亮地区时,隐藏区域标签
              show: false,
            },
          },
        },
  1. 使用散点图来标注地点
    (1)地图默认已有的省份、直辖市和特别行政区名称直接从地图数据中获取,无需手动添加
      let dataList = [];
      /*获取地图中已有的省、直辖市和特别行政区*/
      echarts.getMap("china").geoJson.features.forEach((item) => {
        dataList.push({
          // 地区名称
          name: item.properties.name,
          // 地区经纬度
          value: item.properties.cp,
        });
      });

(2)地图中没有的城市,手动添加城市名和城市坐标

城市坐标可以通过下方网站查询

http://life.chacuo.net/postion/

      // 添加城市——参照青岛的格式,可以添加其他城市
      newCityList: [
        {
          name: "青岛",
          value: [120.4, 36],
        },
      ],
      // 添加城市
      return dataList.concat(this.newCityList);

完整范例代码如下

china.js 的百度网盘下载链接:

https://pan.baidu.com/s/1K0wlmb3Yt223XAykMXpALA

提取码:w160

<template>
  <div class="mapBox">
    <div style="height: 100%;width: 100%" ref="myChart"></div>
  </div>
</template>

<script>
import echarts from "echarts";
import "@/components/charts/chinaMap/china.js";

export default {
  data() {
    return {
      dataList: [],
      // 添加城市——参照青岛的格式,可以添加其他城市
      newCityList: [
        {
          name: "青岛",
          value: [120.4, 36],
        },
      ],
    };
  },
  methods: {
    initData() {
      let dataList = [];
      /*获取地图中已有的省、直辖市和特别行政区*/
      echarts.getMap("china").geoJson.features.forEach((item) => {
        dataList.push({
          // 地区名称
          name: item.properties.name,
          // 地区经纬度
          value: item.properties.cp,
        });
      });
      // 添加城市
      return dataList.concat(this.newCityList);
    },
    initEchartMap() {
      let myChart = echarts.init(this.$refs.myChart);

      let options = {
        geo: {
          map: "china",
          label: {
            emphasis: {
              // 高亮地区时,隐藏区域标签
              show: false,
            },
          },
        },
        series: [
          {
            name: "散点",
            type: "scatter",
            coordinateSystem: "geo",
            data: this.dataList,
            label: {
              show: true,
              // 标签格式化,获取数据中的name
              formatter: "{b}",
              // 标签偏移量 -- 水平偏移,垂直偏移,原点为散点的位置
              offset: [0, -18],
              color: "black",
            },
            emphasis: {
              label: {
                show: true,
                formatter: "{b}",
                offset: [0, -20],
                color: "red",
                fontSize: 18,
              },
            },
          },
        ],
      };

      myChart.setOption(options);

      // 添加窗口大小改变监听事件,当窗口大小改变时,图表会重新绘制,自适应窗口大小
      window.addEventListener("resize", function() {
        myChart.resize();
      });
    },
  },

  mounted() {
    this.$nextTick(() => {
      this.dataList = this.initData();
      this.initEchartMap();
    });
  },
};
</script>
<style scoped>
.mapBox {
  background: #020933;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px;
  box-sizing: border-boxs;
}
</style>

地图优化——自定义散点样式

修改symbol的配置即可实现,上图中使用的是自定义图片

需先使用下方网站将图片转换成base64格式

http://tool.chinaz.com/tools/imgtobase/

作为symbol的属性值,还需在base64的数据前添加 image://

完整范例代码如下:

<template>
  <div class="mapBox">
    <div style="height: 100%;width: 100%" ref="myChart"></div>
  </div>
</template>

<script>
import echarts from "echarts";
import "@/components/charts/chinaMap/china.js";

export default {
  data() {
    return {
      dataList: [],
      // 添加城市——参照青岛的格式,可以添加其他城市
      newCityList: [
        {
          name: "青岛",
          value: [120.4, 36],
        },
      ],
    };
  },
  methods: {
    initData() {
      let dataList = [];
      /*获取地图中已有的省、直辖市和特别行政区*/
      echarts.getMap("china").geoJson.features.forEach((item) => {
        dataList.push({
          // 地区名称
          name: item.properties.name,
          // 地区经纬度
          value: item.properties.cp,
        });
      });
      // 添加城市
      return dataList.concat(this.newCityList);
    },
    initEchartMap() {
      let myMark =
        "image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFMAAABTCAYAAAGUtQuWAAAAAXNSR0IArs4c6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t85regBNM/ZwEtyAKinqBivQ8gJXFmWC8QLPITQMve6QiCyqU2cozjPhoXAr9vppHv18EuZNBifhfg+OZQgCmQcrNnzWPBKwAHsDG4PpOy3QAtQAqcSQ70mZOad0LkdZhWAZBPrU3QArj4jwwUZ7m1cKJl7JcifQNn6zs+OXNj2o0j481lwOwW3BVUDRQdQ20tOVWC1Kma+kImWIb2vdaklmt1CATcAYjuRvwxONLnhrWCjyVgNwNIn0TATBpndljeMvBirYUjHTJ/NEBulPt8L5A+9ywXCm3Qr38duzbslwGMhwBipoWPPcW8ZOieO6Lv47IIN9vg6swfofz4LS19B9VA2V4owB4FXAej3HuWfwUzwA1nsUuA1wJZuFIwvRegCI0JnoGI2b3vBK67jdDNr4oypv50hlaUTVewlTCX42NPMS8ZuufC4js4Ve4gipnN6RsooW69BkgEVh0rx65yNjotRzoQcrOOn1xaOFLfRdEWVJOg70wxucR7465l1heMiOQE9wWnymlGeQoHGg4+Sb4bOJtmXOhdPOOi9NWH+027EbvfsjnfDm71qW6pSf1aJi1XPgV3naNsy3YdpfwK3AbXJiP8JcpvxH8xCY7J0JeHaZ2zwdr97Guf50BLPywAraCkncSWN1d4XgDXWqKNRYB9I9cKskmgTYJtKutR+WbhowRljSeaFFfTRc5OjqYyC3sdouvVFDhvroT7LLdXCsL3evsler4LwKXmWfsF7PKmnOXukgpXlftynoHlkznASpYvNXCl3u75/wMbkWN60cxCCAAAAABJRU5ErkJggg==";

      let myChart = echarts.init(this.$refs.myChart);

      let options = {
        geo: {
          map: "china",
          label: {
            emphasis: {
              // 高亮地区时,隐藏区域标签
              show: false,
            },
          },
        },
        series: [
          {
            symbol: myMark,
            symbolSize: 15,
            name: "散点",
            type: "scatter",
            coordinateSystem: "geo",
            data: this.dataList,
            label: {
              show: true,
              // 标签格式化,获取数据中的name
              formatter: "{b}",
              // 标签偏移量 -- 水平偏移,垂直偏移,原点为散点的位置
              offset: [0, -18],
              color: "black",
            },
            emphasis: {
              label: {
                show: true,
                formatter: "{b}",
                offset: [0, -20],
                color: "red",
                fontSize: 18,
              },
            },
          },
        ],
      };

      myChart.setOption(options);

      // 添加窗口大小改变监听事件,当窗口大小改变时,图表会重新绘制,自适应窗口大小
      window.addEventListener("resize", function() {
        myChart.resize();
      });
    },
  },

  mounted() {
    this.$nextTick(() => {
      this.dataList = this.initData();
      this.initEchartMap();
    });
  },
};
</script>
<style scoped>
.mapBox {
  background: #020933;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px;
  box-sizing: border-boxs;
}
</style>


目录
相关文章
|
定位技术
Echarts使用geojson地理坐标地图地名label标签位置不居中调整的解决方案
Echarts使用geojson地理坐标地图地名label标签位置不居中调整的解决方案
353 0
|
数据可视化 定位技术 Python
基于ArcMap的精美地图可视化绘制--以各省GDP数据为例
大家好,我是志斌~ 今天手把手教大家如何用ArcMap 10.3画分级地图。
1647 0
基于ArcMap的精美地图可视化绘制--以各省GDP数据为例
|
数据可视化 搜索推荐 JavaScript
数据可视化大屏百度地图区域掩膜MapMask实现地图指定区域非省市县行政区显示的实战案例解析(JavaScript API GL、个性化地图定制、指定区域经纬度拾取转化)
数据可视化大屏百度地图区域掩膜MapMask实现地图指定区域非省市县行政区显示的实战案例解析(JavaScript API GL、个性化地图定制、指定区域经纬度拾取转化)
962 0
|
2月前
|
JSON JavaScript 定位技术
Vue结合ECharts绘制省市地图:数据驱动区域颜色展示,支持省市下钻与经纬度打点功能
Vue结合ECharts绘制省市地图:数据驱动区域颜色展示,支持省市下钻与经纬度打点功能
163 0
|
6月前
|
JSON JavaScript 定位技术
Echarts自定义地图显示区域,可以显示街道,小区,学校等区域
Echarts自定义地图显示区域,可以显示街道,小区,学校等区域
|
存储 编解码 定位技术
案例!从天地图中提取全市的建筑物矢量轮廓-以苏州市为例
案例!从天地图中提取全市的建筑物矢量轮廓-以苏州市为例
256 1
|
定位技术 C# Windows
C#编程学习(05):使用webbroswer控件显示地图并标注点位坐标
C#编程学习(05):使用webbroswer控件显示地图并标注点位坐标
|
人工智能 定位技术
如何将国家地图服务系统的EPS地图转为shp图层
如何将国家地图服务系统的EPS地图转为shp图层
1567 0
|
定位技术
Echarts地图开发:geomap全国34省市区cp属性经纬度坐标
Echarts地图开发:geomap全国34省市区cp属性经纬度坐标
103 0
|
JSON 定位技术 API
百度地图高级开发:获取某范围半径圆形区域检索覆盖物内的所有标注的解决方案(1)
百度地图高级开发:获取某范围半径圆形区域检索覆盖物内的所有标注的解决方案(1)
297 0