mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-16 02:51:16 +01:00
Deal with no metadata in style
This commit is contained in:
parent
377840ca24
commit
75ca1fa930
1 changed files with 3 additions and 3 deletions
|
@ -32,7 +32,7 @@ class Gist extends React.Component {
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
this.setState({
|
this.setState({
|
||||||
...this.state,
|
...this.state,
|
||||||
preview: !!nextProps.mapStyle.metadata['maputnik:openmaptiles_access_token']
|
preview: !!(nextProps.mapStyle.metadata || {})['maputnik:openmaptiles_access_token']
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Gist extends React.Component {
|
||||||
...this.state,
|
...this.state,
|
||||||
saving: true
|
saving: true
|
||||||
});
|
});
|
||||||
const preview = this.state.preview && this.props.mapStyle.metadata['maputnik:openmaptiles_access_token'];
|
const preview = this.state.preview && (this.props.mapStyle.metadata || {})['maputnik:openmaptiles_access_token'];
|
||||||
|
|
||||||
const mapStyleStr = preview ?
|
const mapStyleStr = preview ?
|
||||||
formatStyle(stripAccessTokens(style.replaceAccessToken(this.props.mapStyle))) :
|
formatStyle(stripAccessTokens(style.replaceAccessToken(this.props.mapStyle))) :
|
||||||
|
@ -163,7 +163,7 @@ class Gist extends React.Component {
|
||||||
<InputBlock
|
<InputBlock
|
||||||
label={"OpenMapTiles Access Token: "}>
|
label={"OpenMapTiles Access Token: "}>
|
||||||
<StringInput
|
<StringInput
|
||||||
value={this.props.mapStyle.metadata['maputnik:openmaptiles_access_token']}
|
value={(this.props.mapStyle.metadata || {})['maputnik:openmaptiles_access_token']}
|
||||||
onChange={this.changeMetadataProperty.bind(this, "maputnik:openmaptiles_access_token")}/>
|
onChange={this.changeMetadataProperty.bind(this, "maputnik:openmaptiles_access_token")}/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
<a target="_blank" href="https://openmaptiles.com/hosting/">Get your free access token</a>
|
<a target="_blank" href="https://openmaptiles.com/hosting/">Get your free access token</a>
|
||||||
|
|
Loading…
Reference in a new issue