Commit 7a97e2bd authored by alain's avatar alain 🐙
Browse files

fixes for not rendering newly loaded source / offset multiple parameters

parent 7b9e365b
......@@ -42,7 +42,7 @@ class DeckLayers extends React.Component {
layers = memoize(
(deckLayers, setModal, zoom, unitStatus, sources) => {
(deckLayers, setModal, zoom, unitStatus, loading) => {
const layers = []
const count = {}
......@@ -63,6 +63,8 @@ class DeckLayers extends React.Component {
count[sourceName].current++
if(!layerDefinition) return
switch(layerDefinition.type) {
case "StationLayer":
const unit = (layerDefinition.units ? layerDefinition.units.find(x => x.id === unitStatus[layerDefinition.id]) : null)
......@@ -163,15 +165,9 @@ class DeckLayers extends React.Component {
render() {
const { viewport, deckLayers, setModal, unitStatus } = this.props
// add sources count to memoize function as it doesn't detect changes in deckLayers reliably
var sources = 0
Object.keys(deckLayers).forEach(layer => {
sources += Object.keys(deckLayers[layer]).length
})
const { viewport, loading, deckLayers, setModal, unitStatus } = this.props
const layers = this.layers(deckLayers, setModal, viewport.zoom, unitStatus, sources)
const layers = this.layers(deckLayers, setModal, viewport.zoom, unitStatus, loading)
return (
<div>
......
......@@ -51,6 +51,7 @@ class App extends React.Component {
deckLayers: {},
data: null,
layers: initialLayers,
//loaded: 0,
loading: 0,
loadingError: false,
modalContent: null
......@@ -102,6 +103,14 @@ class App extends React.Component {
this.setState({ loading: this.state.loading + layerDefinition.sources.length })
if(!deckLayers[layer]) {
deckLayers[layer] = {}
layerDefinition.sources.forEach(source => {
deckLayers[layer][source.name] = {}
})
}
layerDefinition.sources.forEach(source => {
const dataFunction = source.all
......@@ -112,9 +121,11 @@ class App extends React.Component {
loadingError: true
})
} else {
if(!deckLayers[layer]) deckLayers[layer] = {}
const previousData = Object.values(deckLayers[layer]).map(layer => layer.data)
const previousData = []
Object.keys(deckLayers[layer]).forEach(source => {
if(deckLayers[layer][source].data) previousData.push(deckLayers[layer][source].data)
})
//const previousData = Object.values(deckLayers[layer]).map(source => source.data)
deckLayers[layer][source.name] = {
layerDefinition,
......@@ -124,6 +135,7 @@ class App extends React.Component {
this.setState({
deckLayers,
//loaded: this.state.loaded + 1,
loading: this.state.loading - 1
})
}
......@@ -227,7 +239,7 @@ class App extends React.Component {
return (
<div id="app">
<MapGL { ...viewport } width="100%" height="100%" maxPitch={pitchMax} maxZoom={zoomMax} minZoom={zoomMin} onViewportChange={ this.onViewportChange } mapStyle={mapStyle} onTransitionStart={() => { this.setTransitionState(true) } } onTransitionEnd={() => { this.setTransitionState(false) } }>
<DeckLayers viewport={viewport} deckLayers={deckLayers} setModal={ this.setModal } />
<DeckLayers viewport={viewport} loading={loading} deckLayers={deckLayers} setModal={ this.setModal } />
</MapGL>
<MapControls mapControlSettings={mapControlSettings} viewport={viewport} changeViewport={this.changeViewport} />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment