Allow download style

This commit is contained in:
lukasmartinelli
2016-09-09 16:58:48 +02:00
parent 52e4c92ccf
commit 3cc989e70f
5 changed files with 42 additions and 15 deletions
+8 -1
View File
@@ -1,4 +1,5 @@
import React from 'react'
import {saveAs} from 'file-saver'
import { Drawer, Container, Block, Fixed } from 'rebass'
import {Map} from './map.jsx'
@@ -49,6 +50,12 @@ export default class App extends React.Component {
}
}
onStyleDownload() {
const mapStyle = this.state.styleManager.exportStyle()
const blob = new Blob([mapStyle], {type: "application/json;charset=utf-8"});
saveAs(blob, "glstyle.json");
}
onStyleUpload(newStyle) {
this.setState({ styleManager: new StyleManager(newStyle) })
}
@@ -64,7 +71,7 @@ export default class App extends React.Component {
render() {
return <div style={{ fontFamily: theme.fontFamily, color: theme.color }}>
<Toolbar onStyleUpload={this.onStyleUpload.bind(this)} />
<Toolbar onStyleUpload={this.onStyleUpload.bind(this)} onStyleDownload={this.onStyleDownload.bind(this)} />
<WorkspaceDrawer styleManager={this.state.styleManager}/>
<div className={layout.map}>
<Map styleManager={this.state.styleManager} />