From 604be38b7ccbc6a4ba7bb723788bc4c2f2f8d9c8 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 28 Dec 2016 17:08:42 +0100 Subject: [PATCH] Store highlighted layer in metadata --- src/components/App.jsx | 17 +++++++++++++++++ src/components/layers/LayerEditor.jsx | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index 668862d..b4aeeb4 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -110,6 +110,20 @@ export default class App extends React.Component { 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) { const changedLayers = this.state.mapStyle.layers.slice(0) const idx = style.indexOfLayer(changedLayers, layer.id) @@ -153,6 +167,7 @@ export default class App extends React.Component { render() { const layers = this.state.mapStyle.layers || [] const selectedLayer = layers.length > 0 ? layers[this.state.selectedLayerIndex] : null + const metadata = this.state.mapStyle.metadata || {} const toolbar = : null return this.props.onHighlightLayerChange(v === "highlight")} /> @@ -157,6 +160,7 @@ export default class LayerEditor extends React.Component { } render() { + console.log(this.props) const layerType = this.props.layer.type const layoutGroups = layout[layerType].groups.filter(group => { return !(this.props.layer.type === 'background' && group.type === 'source')