mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-15 04:41:19 +01:00
Only update style if it is valid
This commit is contained in:
parent
3be3a716d4
commit
1f1a919c77
1 changed files with 10 additions and 3 deletions
|
@ -10,6 +10,8 @@ import LayerEditor from './layers/LayerEditor'
|
||||||
import Toolbar from './Toolbar'
|
import Toolbar from './Toolbar'
|
||||||
import AppLayout from './AppLayout'
|
import AppLayout from './AppLayout'
|
||||||
|
|
||||||
|
import GlSpec from 'mapbox-gl-style-spec/reference/latest.js'
|
||||||
|
import validateStyleMin from 'mapbox-gl-style-spec/lib/validate_style.min'
|
||||||
import style from '../libs/style.js'
|
import style from '../libs/style.js'
|
||||||
import { loadDefaultStyle, StyleStore } from '../libs/stylestore'
|
import { loadDefaultStyle, StyleStore } from '../libs/stylestore'
|
||||||
import { ApiStyleStore } from '../libs/apistore'
|
import { ApiStyleStore } from '../libs/apistore'
|
||||||
|
@ -71,9 +73,14 @@ export default class App extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onStyleChanged(newStyle) {
|
onStyleChanged(newStyle) {
|
||||||
this.revisionStore.addRevision(newStyle)
|
const errors = validateStyleMin(newStyle, GlSpec)
|
||||||
this.saveStyle(newStyle)
|
if(errors.length === 0) {
|
||||||
this.setState({ mapStyle: newStyle })
|
this.revisionStore.addRevision(newStyle)
|
||||||
|
this.saveStyle(newStyle)
|
||||||
|
this.setState({ mapStyle: newStyle })
|
||||||
|
} else {
|
||||||
|
errors.forEach(err => console.error(err.message))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onUndo() {
|
onUndo() {
|
||||||
|
|
Loading…
Reference in a new issue