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