Hide sources when adding background layer

This commit is contained in:
Lukas Martinelli 2016-12-30 17:06:08 +01:00
parent bda7ce7390
commit 1058dbfb5a

View file

@ -25,12 +25,17 @@ class AddModal extends React.Component {
addLayer() { addLayer() {
const changedLayers = this.props.mapStyle.layers.slice(0) const changedLayers = this.props.mapStyle.layers.slice(0)
changedLayers.push({ const layer = {
id: this.state.id, id: this.state.id,
type: this.state.type, type: this.state.type,
source: this.state.source, }
'source-layer': this.state['source-layer'],
}) if(this.state.type !== 'background') {
layer.source = this.state.source
layer['source-layer'] = this.state['source-layer']
}
changedLayers.push(layer)
const changedStyle = { const changedStyle = {
...this.props.mapStyle, ...this.props.mapStyle,
@ -79,16 +84,20 @@ class AddModal extends React.Component {
value={this.state.type} value={this.state.type}
onChange={v => this.setState({ type: v })} onChange={v => this.setState({ type: v })}
/> />
{this.state.type !== 'background' &&
<LayerSourceBlock <LayerSourceBlock
sourceIds={Object.keys(this.props.sources)} sourceIds={Object.keys(this.props.sources)}
value={this.state.source} value={this.state.source}
onChange={v => this.setState({ source: v })} onChange={v => this.setState({ source: v })}
/> />
}
{this.state.type !== 'background' &&
<LayerSourceLayerBlock <LayerSourceLayerBlock
sourceLayerIds={this.props.sources[this.state.source] || []} sourceLayerIds={this.props.sources[this.state.source] || []}
value={this.state['source-layer']} value={this.state['source-layer']}
onChange={v => this.setState({ 'source-layer': v })} onChange={v => this.setState({ 'source-layer': v })}
/> />
}
<Button onClick={this.addLayer.bind(this)}> <Button onClick={this.addLayer.bind(this)}>
Add Layer Add Layer
</Button> </Button>