From a609dc4029188bc48439d128302238b247963529 Mon Sep 17 00:00:00 2001 From: pathmapper Date: Sun, 16 Jun 2019 05:27:53 +0200 Subject: [PATCH] Set default renderer if undefined --- src/components/App.jsx | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index cc598f5..d9a4bce 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -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() { const sourceList = {...this.state.sources}; @@ -582,7 +603,7 @@ export default class App extends React.Component { this.setState({ mapboxGlDebugOptions: { ...this.state.mapboxGlDebugOptions, - [key]: value, + [key]: value, } }); } @@ -669,7 +690,7 @@ export default class App extends React.Component { />