diff --git a/package.json b/package.json index 419fe64..2483747 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "license": "MIT", "homepage": "https://github.com/lukasmartinelli/mapolo#readme", "dependencies": { + "file-saver": "^1.3.2", "mapbox-gl": "^0.23.0", "mapbox-gl-style-spec": "^8.8.0", "node-sass": "^3.9.2", diff --git a/src/app.jsx b/src/app.jsx index fc0d92e..89adb40 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -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