Format style on download

This commit is contained in:
jirik 2017-01-06 15:48:57 +01:00
parent c9fd00e2ed
commit cb46ac5421

View file

@ -13,6 +13,7 @@ import MessagePanel from './MessagePanel'
import GlSpec from 'mapbox-gl-style-spec/reference/latest.js' import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
import validateStyleMin from 'mapbox-gl-style-spec/lib/validate_style.min' import validateStyleMin from 'mapbox-gl-style-spec/lib/validate_style.min'
import formatStyle from 'mapbox-gl-style-spec/lib/format'
import style from '../libs/style.js' import style from '../libs/style.js'
import { initialStyleUrl, loadStyleUrl } from '../libs/urlopen' import { initialStyleUrl, loadStyleUrl } from '../libs/urlopen'
import { undoMessages, redoMessages } from '../libs/diffmessage' import { undoMessages, redoMessages } from '../libs/diffmessage'
@ -76,7 +77,7 @@ export default class App extends React.Component {
onStyleDownload() { onStyleDownload() {
const mapStyle = this.state.mapStyle const mapStyle = this.state.mapStyle
const blob = new Blob([JSON.stringify(mapStyle, null, 4)], {type: "application/json;charset=utf-8"}); const blob = new Blob([formatStyle(mapStyle)], {type: "application/json;charset=utf-8"});
saveAs(blob, mapStyle.id + ".json"); saveAs(blob, mapStyle.id + ".json");
} }
@ -224,4 +225,3 @@ export default class App extends React.Component {
/> />
} }
} }