* @function Graph.prototype.redrawThematicFeatures * @description 重绘所有专题要素。 * 此方法包含绘制专题要素的所有步骤,包含用户数据到专题要素的转换,抽稀,缓存等步骤。 * 地图漫游时调用此方法进行图层刷新。 * @param {Object} extent - 重绘的范围。 *
(extent)
| 115 | * |
| 116 | */ |
| 117 | redrawThematicFeatures(extent) { |
| 118 | //清除当前所有可视元素 |
| 119 | this.renderer.clearAll(); |
| 120 | var features = this.features; |
| 121 | for (var i = 0, len = features.length; i < len; i++) { |
| 122 | var feature = features[i]; |
| 123 | // 要素范围判断 |
| 124 | var feaBounds = feature.geometry.getBounds(); |
| 125 | //剔除当前视图(地理)范围以外的数据 |
| 126 | if (extent) { |
| 127 | var bounds = new Bounds(extent[0], extent[1], extent[2], extent[3]); |
| 128 | if (!bounds.intersectsBounds(feaBounds)) { |
| 129 | continue; |
| 130 | } |
| 131 | } |
| 132 | var cache = this.cache; |
| 133 | // 用 feature id 做缓存标识 |
| 134 | var cacheField = feature.id; |
| 135 | // 数据对应的图表是否已缓存,没缓存则重新创建图表 |
| 136 | if (cache[cacheField]) { |
| 137 | continue; |
| 138 | } |
| 139 | cache[cacheField] = cacheField; |
| 140 | var chart = this.createThematicFeature(feature); |
| 141 | // 压盖处理权重值 |
| 142 | if (chart && this.overlayWeightField) { |
| 143 | if (feature.attributes[this.overlayWeightField] && !isNaN(feature.attributes[this.overlayWeightField])) { |
| 144 | chart["__overlayWeight"] = feature.attributes[this.overlayWeightField]; |
| 145 | } |
| 146 | } |
| 147 | if (chart) { |
| 148 | this.charts.push(chart); |
| 149 | } |
| 150 | } |
| 151 | this.drawCharts(); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * @function Graph.prototype.createThematicFeature |
no test coverage detected