fuliqi
2024-09-24 4e2670a63c0ccb399f8c51837a851a8cca3688da
src/views/screen/components/map3.vue
@@ -14,12 +14,53 @@
      type: Object,
      default: {},
    },
    platformData: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      myChart: null, // ECharts 实例
      big: 130,
      data: [
      dotData: [
        {
          name: '自流井区',
          value: [104.665471408, 29.23008885, 300],
          platformOnline: true
        },
        {
          name: '高新区',
          value: [104.805193, 29.3, 300],
          platformOnline: true
        },
        {
          name: '大安区',
          value: [104.90805, 29.345946, 300],
          platformOnline: true
        },
        {
          name: '沿滩区',
          value: [104.80804, 29.200594, 300],
          platformOnline: true
        },
        {
          name: '贡井区',
          value: [104.579106, 29.241427, 300],
          platformOnline: true
        },
        {
          name: '荣县',
          value: [104.3534, 29.3538, 300],
          platformOnline: true
        },
        {
          name: '富顺县',
          value: [104.96, 29.08, 300],
          platformOnline: true
        }
      ],
      markData: [
        {
          name: '自流井区',
          number: '0',
@@ -72,11 +113,21 @@
      this.getChinData('自贡市', chinaJson)
    },
    updateMapData() {
      this.data.forEach(item => {
        if (this.geoCoordinates[item.name]) {
          item.number = this.geoCoordinates[item.name].score || '0'
        }
      })
      if (this.geoCoordinates) {
        this.markData.forEach(item => {
          if (this.geoCoordinates[item.name]) {
            item.number = this.geoCoordinates[item.name].score || '0'
          }
        })
      }
      if (this.platformData) {
        this.dotData.forEach(item => {
          console.log('更新数据', this.platformData)
          if (this.platformData[item.name]) {
            item.platformOnline = this.platformData[item.name].platformOnline
          }
        })
      }
    },
    updateChart() {
      if (this.myChart) {
@@ -84,7 +135,11 @@
        // Update the scatter3D series data
        const scatterSeries = option.series.find(s => s.type === 'scatter3D' && s.name !== '散点图');
        if (scatterSeries) {
          scatterSeries.data = this.data;
          scatterSeries.data = this.markData;
        }
        const dotSeries = option.series.find(s => s.type === 'scatter3D' && s.name === '散点图');
        if (dotSeries) {
          dotSeries.data = this.dotData;
        }
        this.myChart.setOption(option);
      }
@@ -250,41 +305,18 @@
            silent: true,
            itemStyle: {
              color: '#fc840e',
              color: function (param) {
                if (param.data.platformOnline) {
                  return '#04CD44';
                } else {
                  return '#FF0756';
                }
              },
              borderWidth: 1,
              borderColor: '#fff'
            },
            data: [
              {
                name: '自流井区',
                value: [104.665471408, 29.23008885, 300]
              },
              {
                name: '高新区',
                value: [104.805193, 29.3, 300]
              },
              {
                name: '大安区',
                value: [104.90805, 29.345946, 300]
              },
              {
                name: '沿滩区',
                value: [104.80804, 29.200594, 300]
              },
              {
                name: '贡井区',
                value: [104.579106, 29.241427, 300]
              },
              {
                name: '荣县',
                value: [104.3534, 29.3538, 300]
              },
              {
                name: '富顺县',
                value: [104.96, 29.08, 300]
              }
            ]
            data: that.dotData
          },
          {
            type: 'lines3D',
@@ -355,12 +387,12 @@
        coordinateSystem: 'geo3D',
        symbol: 'circle',
        symbolSize: 0,
        data: that.data,
        data: that.markData,
        itemStyle: {
          opacity: 1,
          borderWidth: 1,
          borderColor: 'a4ddee'
          borderColor: 'a4ddee',
        },
        label: {
@@ -404,6 +436,13 @@
        this.updateChart();
      },
      deep: true
    },
    platformData: {
      handler(newValue) {
        this.updateMapData(newValue);
        this.updateChart();
      },
      deep: true
    }
  },
}