美文网首页univue系列
js echarts获取市下县的区块信息

js echarts获取市下县的区块信息

作者: litielongxx | 来源:发表于2024-01-11 11:29 被阅读0次

https://datav.aliyun.com/portal/school/atlas/area_selector

image.png
主要根据城市id,通过接口动态查询市下县的区块大小和形状信息
 getAreaInfo: function (cityName) {
      // 设置基本的API URL
      // 示范城市id 421100
      const code = 421100
      const baseUrl = 'https://geo.datav.aliyun.com/areas_v3/bound/geojson'
      // 使用Axios发送GET请求,并动态添加查询参数
      this.$axios
        .get(baseUrl, {
          params: {
            code: `${code}_full`
          }
        })
        .then(res => {
          // 处理API响应数据
          this.chartMap(res.data)
          // 将响应数据存储到Vue组件的数据中
        })
        .catch(error => {
          // 处理错误
        })
    },

数据格式返回为这种才能直接用在echart下


image.png

相关文章

网友评论

    本文标题:js echarts获取市下县的区块信息

    本文链接:https://www.haomeiwen.com/subject/nqstodtx.html