mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 18:21:17 +01:00
Switch map renderer based on state
This commit is contained in:
parent
71de62565b
commit
43573fcd8c
1 changed files with 8 additions and 5 deletions
13
src/app.jsx
13
src/app.jsx
|
@ -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>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue