Switch map renderer based on state

This commit is contained in:
Lukas Martinelli 2016-12-16 15:14:20 +01:00
parent 71de62565b
commit 43573fcd8c

View file

@ -39,7 +39,8 @@ export default class App extends React.Component {
this.state = { this.state = {
accessToken: this.settingsStore.accessToken, accessToken: this.settingsStore.accessToken,
workContext: "layers", workContext: "layers",
currentStyle: style.emptyStyle currentStyle: style.emptyStyle,
mapRenderer: 'gl',
} }
} }
@ -99,6 +100,10 @@ export default class App extends React.Component {
} }
render() { render() {
const mapProps = {
mapStyle: this.state.currentStyle,
accessToken: this.state.accessToken,
}
return <div style={{ fontFamily: theme.fontFamily, color: theme.color, fontWeight: 300 }}> return <div style={{ fontFamily: theme.fontFamily, color: theme.color, fontWeight: 300 }}>
<Toolbar <Toolbar
styleAvailable={this.state.currentStyle.get('layers').size > 0} styleAvailable={this.state.currentStyle.get('layers').size > 0}
@ -117,10 +122,8 @@ export default class App extends React.Component {
accessToken={this.state.accessToken} accessToken={this.state.accessToken}
onAccessTokenChanged={this.onAccessTokenChanged.bind(this)} onAccessTokenChanged={this.onAccessTokenChanged.bind(this)}
/> />
<OpenLayers3Map {this.state.mapRenderer == 'ol3' && <OpenLayers3Map {...mapProps} />}
mapStyle={this.state.currentStyle} {this.state.mapRenderer == 'gl' && <MapboxGlMap {...mapProps} />}
accessToken={this.state.accessToken}
/>
</div> </div>
} }
} }