diff options
| author | Yuval Adam <yuval@y3xz.com> | 2016-01-09 20:37:08 +0200 |
|---|---|---|
| committer | Yuval Adam <yuval@y3xz.com> | 2016-01-09 20:37:08 +0200 |
| commit | 7d6aa9f1de5e0597a1942c0f4b7b97769b727f26 (patch) | |
| tree | 2c40098788cb5df830a1e6581f7d90d0cf1b9222 /geshem.js | |
| parent | 2154522c3b2cf46047c51c2d7ea0a9fe1fcd75a6 (diff) | |
Fix performance issues
Diffstat (limited to 'geshem.js')
| -rw-r--r-- | geshem.js | 39 |
1 files changed, 26 insertions, 13 deletions
@@ -59,14 +59,18 @@ class GLMap extends React.Component { "source": 'radar-' + res + '-' + i, "type": "raster", "paint": { - "raster-opacity": 0 - }, + "raster-opacity": 0.85 + } // "layout": { // "visibility": "none" // } }) } + _removeRadarLayer (res, i) { + this.map.removeLayer('radar-' + res + '-' + i) + } + componentDidMount () { mapboxgl.accessToken = this.props.token @@ -74,16 +78,20 @@ class GLMap extends React.Component { this.map.on('zoom', (e) => { if (this.map.getZoom() > 7) { - this.map.setPaintProperty('radar-140-' + this.state.slider, 'raster-opacity', 0.85) - this.map.setPaintProperty('radar-280-' + this.state.slider, 'raster-opacity', 0) + // this.map.setPaintProperty('radar-140-' + this.state.slider, 'raster-opacity', 0.85) + // this.map.setPaintProperty('radar-280-' + this.state.slider, 'raster-opacity', 0) + this._removeRadarLayer('280', this.state.slider) + this._addRadarLayer('140', this.state.slider) this.setState({ 'res': '140', 'slider': this.state.slider }) } else { - this.map.setPaintProperty('radar-140-' + this.state.slider, 'raster-opacity', 0) - this.map.setPaintProperty('radar-280-' + this.state.slider, 'raster-opacity', 0.85) + // this.map.setPaintProperty('radar-140-' + this.state.slider, 'raster-opacity', 0) + // this.map.setPaintProperty('radar-280-' + this.state.slider, 'raster-opacity', 0.85) + this._removeRadarLayer('140', this.state.slider) + this._addRadarLayer('280', this.state.slider) this.setState({ 'res': '280', 'slider': this.state.slider @@ -94,22 +102,27 @@ class GLMap extends React.Component { this.map.on('style.load', () => { var i = 0; for (let v of window.imgs['140']) { - this._addRadarSource('140', i, v) - this._addRadarLayer('140', i++) + this._addRadarSource('140', i++, v) + // this._addRadarLayer('140', i++) } i = 0; for (let v of window.imgs['280']) { - this._addRadarSource('280', i, v) - this._addRadarLayer('280', i++) + this._addRadarSource('280', i++, v) + // this._addRadarLayer('280', i++) } - this.map.setPaintProperty('radar-280-0', 'raster-opacity', 0.85) + // this.map.setPaintProperty('radar-280-0', 'raster-opacity', 0.85) + this._addRadarLayer('280', '0') }) } componentWillReceiveProps (props) { - this.map.setPaintProperty('radar-' + this.state.res + '-' + this.state.slider, 'raster-opacity', 0) - this.map.setPaintProperty('radar-' + this.state.res + '-' + props.slider, 'raster-opacity', 0.85) + // this.map.setPaintProperty('radar-' + this.state.res + '-' + this.state.slider, 'raster-opacity', 0) + // this.map.setPaintProperty('radar-' + this.state.res + '-' + props.slider, 'raster-opacity', 0.85) + + this._removeRadarLayer(this.state.res, this.state.slider) + this._addRadarLayer(this.state.res, props.slider) + this.setState({ 'res': this.state.res, 'slider': props.slider |
