Merge pull request #528 from pathmapper/renderer_metadata

Set default renderer if undefined
This commit is contained in:
Orange Mug 2019-06-16 10:03:37 +01:00 committed by GitHub
commit 7a172b2022
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -434,6 +434,27 @@ export default class App extends React.Component {
}) })
} }
setDefaultValues = (styleObj) => {
const metadata = styleObj.metadata || {}
if(metadata['maputnik:renderer'] === undefined) {
const changedStyle = {
...styleObj,
metadata: {
...styleObj.metadata,
'maputnik:renderer': 'mbgljs'
}
}
return changedStyle
} else {
return styleObj
}
}
openStyle = (styleObj) => {
styleObj = this.setDefaultValues(styleObj)
this.onStyleChanged(styleObj)
}
fetchSources() { fetchSources() {
const sourceList = {...this.state.sources}; const sourceList = {...this.state.sources};
@ -669,7 +690,7 @@ export default class App extends React.Component {
/> />
<OpenModal <OpenModal
isOpen={this.state.isOpen.open} isOpen={this.state.isOpen.open}
onStyleOpen={this.onStyleChanged} onStyleOpen={this.openStyle}
onOpenToggle={this.toggleModal.bind(this, 'open')} onOpenToggle={this.toggleModal.bind(this, 'open')}
/> />
<SourcesModal <SourcesModal