mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 16:51:20 +01:00
Only show 'switch to layer' button if layer not already selected.
This commit is contained in:
parent
adea3d0f13
commit
39333953d7
2 changed files with 15 additions and 8 deletions
|
@ -732,6 +732,7 @@ export default class App extends React.Component {
|
||||||
/> : null
|
/> : null
|
||||||
|
|
||||||
const bottomPanel = (this.state.errors.length + this.state.infos.length) > 0 ? <MessagePanel
|
const bottomPanel = (this.state.errors.length + this.state.infos.length) > 0 ? <MessagePanel
|
||||||
|
currentLayer={selectedLayer}
|
||||||
onLayerSelect={this.onLayerSelect}
|
onLayerSelect={this.onLayerSelect}
|
||||||
mapStyle={this.state.mapStyle}
|
mapStyle={this.state.mapStyle}
|
||||||
errors={this.state.errors}
|
errors={this.state.errors}
|
||||||
|
|
|
@ -7,6 +7,7 @@ class MessagePanel extends React.Component {
|
||||||
infos: PropTypes.array,
|
infos: PropTypes.array,
|
||||||
mapStyle: PropTypes.object,
|
mapStyle: PropTypes.object,
|
||||||
onLayerSelect: PropTypes.func,
|
onLayerSelect: PropTypes.func,
|
||||||
|
currentLayer: PropTypes.object,
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
@ -18,11 +19,14 @@ class MessagePanel extends React.Component {
|
||||||
let content;
|
let content;
|
||||||
if (error.parsed && error.parsed.type === "layer") {
|
if (error.parsed && error.parsed.type === "layer") {
|
||||||
const {parsed} = error;
|
const {parsed} = error;
|
||||||
const {mapStyle} = this.props;
|
const {mapStyle, currentLayer} = this.props;
|
||||||
const layerId = mapStyle.layers[parsed.data.index].id;
|
const layerId = mapStyle.layers[parsed.data.index].id;
|
||||||
content = (
|
content = (
|
||||||
<>
|
<>
|
||||||
Layer <span>'{layerId}'</span>: {parsed.data.message} —
|
Layer <span>'{layerId}'</span>: {parsed.data.message}
|
||||||
|
{currentLayer.id !== layerId &&
|
||||||
|
<>
|
||||||
|
—
|
||||||
<button
|
<button
|
||||||
className="maputnik-message-panel__switch-button"
|
className="maputnik-message-panel__switch-button"
|
||||||
onClick={() => this.props.onLayerSelect(layerId)}
|
onClick={() => this.props.onLayerSelect(layerId)}
|
||||||
|
@ -30,6 +34,8 @@ class MessagePanel extends React.Component {
|
||||||
switch to layer
|
switch to layer
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
|
}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue