js生成色斑图

// 生成气象要素色斑图
    geoColorLayer() {
      var colors = this.weatherData[1].items.reverse();
      var datas = this.weatherData[2].features;
      var features = [];
      datas.forEach(regionItem => {
        regionItem.geometry.coordinates.forEach(polygon => {
          var multiPolygon = polygon.map(line => {
            // 边界点
            var points = line.map(point => {
              return new SuperMap.Geometry.Point(point[0], point[1]);
            });
            // 点连线
            return new SuperMap.Geometry.LinearRing(points);
          });
          // 由线生成岛洞图
          var region = new SuperMap.Geometry.Polygon(multiPolygon);
          var regionVector = new SuperMap.Feature.Vector(region);
          var MGMinValue = regionItem.properties.MGMinValue;
          var MGMaxValue = regionItem.properties.MGMaxValue;
          // 填色
          MGMinValue = MGMinValue <= -90 ? MGMaxValue : MGMinValue;
          colors.some(colorStyle => {
            if (MGMinValue >= colorStyle.Value) {
              regionVector.style = {
                fillColor: colorStyle.FillStyle.ForeColor,
                fillOpacity: 1,
                strokeWidth: 0
              };
              return true;
            }
          });
          features.push(regionVector);
        });
      });
      this.weatherLayer.addFeatures(features);
      // if(this.getWeather) {
      //   this.map.addLayer(this.weatherLayer)
      //   this.getWeather = false
      // }
      this.weatherLayer.setOpacity(0.8);
      this.weatherLayer.setVisibility(this.showWeatherLayer);
    },

 

你可能感兴趣的:(js生成色斑图)