| 157 | } |
| 158 | |
| 159 | async _handleFeatures(bounds) { |
| 160 | let iter = await this.renderer._loadData(bounds); |
| 161 | const features = await this.renderer.iterateFeatures(iter); |
| 162 | if (!this.map.getSource(this.sourceId)) { |
| 163 | this.map.addSource(this.sourceId, { |
| 164 | type: 'geojson', |
| 165 | data: features |
| 166 | }); |
| 167 | } else { |
| 168 | this.map.getSource(this.sourceId).setData(features); |
| 169 | } |
| 170 | if (!this.map.getLayer(this.layerId)) { |
| 171 | this.layerType = this.renderer.layerType; |
| 172 | const layer = Object.assign({ |
| 173 | id: this.layerId, |
| 174 | type: this.layerType, |
| 175 | source: this.sourceId, |
| 176 | paint: Object.assign(PAINT_MAP[this.layerType], this.options.paint) || {}, |
| 177 | layout: this.options.layout || {} |
| 178 | }); |
| 179 | this.map.addLayer(layer); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | async _updateFeatures() { |
| 184 | const bounds = this.map.getBounds().toArray(); |