mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-29 07:30:32 +01:00
Hide sources when adding background layer
This commit is contained in:
parent
bda7ce7390
commit
1058dbfb5a
1 changed files with 13 additions and 4 deletions
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue