mirror of
https://github.com/maputnik/editor.git
synced 2026-06-17 04:37:25 +00:00
Store highlighted layer in metadata
This commit is contained in:
@@ -110,6 +110,20 @@ export default class App extends React.Component {
|
|||||||
this.onLayersChange(changedLayers)
|
this.onLayersChange(changedLayers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changeHighlightedLayer(highlight) {
|
||||||
|
const metadata = this.state.mapStyle.metadata || {}
|
||||||
|
const layers = this.state.mapStyle.layers
|
||||||
|
const highlightedLayer = highlight ? layers[this.state.selectedLayerIndex].id : null
|
||||||
|
|
||||||
|
const changedStyle = {
|
||||||
|
...this.state.mapStyle,
|
||||||
|
metadata: {
|
||||||
|
'maputnik:highlighted_layer': highlightedLayer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.onStyleChanged(changedStyle)
|
||||||
|
}
|
||||||
|
|
||||||
onLayerChanged(layer) {
|
onLayerChanged(layer) {
|
||||||
const changedLayers = this.state.mapStyle.layers.slice(0)
|
const changedLayers = this.state.mapStyle.layers.slice(0)
|
||||||
const idx = style.indexOfLayer(changedLayers, layer.id)
|
const idx = style.indexOfLayer(changedLayers, layer.id)
|
||||||
@@ -153,6 +167,7 @@ export default class App extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const layers = this.state.mapStyle.layers || []
|
const layers = this.state.mapStyle.layers || []
|
||||||
const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null
|
const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null
|
||||||
|
const metadata = this.state.mapStyle.metadata || {}
|
||||||
|
|
||||||
const toolbar = <Toolbar
|
const toolbar = <Toolbar
|
||||||
mapStyle={this.state.mapStyle}
|
mapStyle={this.state.mapStyle}
|
||||||
@@ -172,8 +187,10 @@ export default class App extends React.Component {
|
|||||||
layer={selectedLayer}
|
layer={selectedLayer}
|
||||||
sources={this.layerWatcher.sources}
|
sources={this.layerWatcher.sources}
|
||||||
vectorLayers={this.layerWatcher.vectorLayers}
|
vectorLayers={this.layerWatcher.vectorLayers}
|
||||||
|
highlightLayer={metadata['maputnik:highlighted_layer'] ? true : false}
|
||||||
onLayerChanged={this.onLayerChanged.bind(this)}
|
onLayerChanged={this.onLayerChanged.bind(this)}
|
||||||
onLayerIdChange={this.onLayerIdChange.bind(this)}
|
onLayerIdChange={this.onLayerIdChange.bind(this)}
|
||||||
|
onHighlightLayerChange={this.changeHighlightedLayer.bind(this)}
|
||||||
/> : null
|
/> : null
|
||||||
|
|
||||||
return <AppLayout
|
return <AppLayout
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ export default class LayerEditor extends React.Component {
|
|||||||
layer: React.PropTypes.object.isRequired,
|
layer: React.PropTypes.object.isRequired,
|
||||||
sources: React.PropTypes.object,
|
sources: React.PropTypes.object,
|
||||||
vectorLayers: React.PropTypes.object,
|
vectorLayers: React.PropTypes.object,
|
||||||
|
highlightLayer: React.PropTypes.bool,
|
||||||
|
onHighlightLayerChange: React.PropTypes.func,
|
||||||
onLayerChanged: React.PropTypes.func,
|
onLayerChanged: React.PropTypes.func,
|
||||||
onLayerIdChange: React.PropTypes.func,
|
onLayerIdChange: React.PropTypes.func,
|
||||||
}
|
}
|
||||||
@@ -138,8 +140,9 @@ export default class LayerEditor extends React.Component {
|
|||||||
/>
|
/>
|
||||||
<InputBlock label={"Inspection Mode"}>
|
<InputBlock label={"Inspection Mode"}>
|
||||||
<MultiButtonInput
|
<MultiButtonInput
|
||||||
value={"highlight"}
|
value={this.props.highlightLayer ? "highlight" : "normal"}
|
||||||
options={[["highlight", "Highlight"], ["normal", "Normal"]]}
|
options={[["highlight", "Highlight"], ["normal", "Normal"]]}
|
||||||
|
onChange={v => this.props.onHighlightLayerChange(v === "highlight")}
|
||||||
/>
|
/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
</div>
|
</div>
|
||||||
@@ -157,6 +160,7 @@ export default class LayerEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
console.log(this.props)
|
||||||
const layerType = this.props.layer.type
|
const layerType = this.props.layer.type
|
||||||
const layoutGroups = layout[layerType].groups.filter(group => {
|
const layoutGroups = layout[layerType].groups.filter(group => {
|
||||||
return !(this.props.layer.type === 'background' && group.type === 'source')
|
return !(this.props.layer.type === 'background' && group.type === 'source')
|
||||||
|
|||||||
Reference in New Issue
Block a user