mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 16:21:16 +01:00
Fix layer editor propagation problem
This commit is contained in:
parent
a05881a078
commit
db8fc64eb9
1 changed files with 8 additions and 8 deletions
16
src/app.jsx
16
src/app.jsx
|
@ -41,7 +41,7 @@ export default class App extends React.Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
accessToken: this.settingsStore.accessToken,
|
accessToken: this.settingsStore.accessToken,
|
||||||
mapStyle: style.emptyStyle,
|
mapStyle: style.emptyStyle,
|
||||||
selectedLayer: null,
|
selectedLayerId: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +91,10 @@ export default class App extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onLayerChanged(layer) {
|
onLayerChanged(layer) {
|
||||||
console.log(layer)
|
console.log('layer changed', layer)
|
||||||
const changedStyle = this.state.mapStyle.setIn('layers', layer.get('id'), layer)
|
const layers = this.state.mapStyle.get('layers')
|
||||||
this.onStyleChanged(changedStyle)
|
const changedLayers = layers.set(layer.get('id'), layer)
|
||||||
|
this.onLayersChanged(changedLayers)
|
||||||
}
|
}
|
||||||
|
|
||||||
onLayerChanged(layer) {
|
onLayerChanged(layer) {
|
||||||
|
@ -115,12 +116,11 @@ export default class App extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onLayerSelected(layerId) {
|
onLayerSelected(layerId) {
|
||||||
this.setState({
|
this.setState({ selectedLayerId: layerId })
|
||||||
selectedLayer: this.state.mapStyle.getIn(['layers', layerId],null)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const selectedLayer = this.state.mapStyle.getIn(['layers', this.state.selectedLayerId], null)
|
||||||
return <div style={{ fontFamily: theme.fontFamily, color: theme.color, fontWeight: 300 }}>
|
return <div style={{ fontFamily: theme.fontFamily, color: theme.color, fontWeight: 300 }}>
|
||||||
<Toolbar
|
<Toolbar
|
||||||
mapStyle={this.state.mapStyle}
|
mapStyle={this.state.mapStyle}
|
||||||
|
@ -156,7 +156,7 @@ export default class App extends React.Component {
|
||||||
width: 300,
|
width: 300,
|
||||||
backgroundColor: colors.gray}
|
backgroundColor: colors.gray}
|
||||||
}>
|
}>
|
||||||
{this.state.selectedLayer && <LayerEditor layer={this.state.selectedLayer} onLayerChanged={this.onLayerChanged.bind(this)} />}
|
{selectedLayer && <LayerEditor layer={selectedLayer} onLayerChanged={this.onLayerChanged.bind(this)} />}
|
||||||
</div>
|
</div>
|
||||||
{this.mapRenderer()}
|
{this.mapRenderer()}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue