mirror of
https://github.com/maputnik/editor.git
synced 2025-12-26 08:00:01 +00:00
Add support local Maputnik
This commit is contained in:
@@ -24,8 +24,10 @@ import LayerWatcher from '../libs/layerwatcher'
|
||||
export default class App extends React.Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.styleStore = new ApiStyleStore()
|
||||
this.revisionStore = new RevisionStore()
|
||||
this.styleStore = new ApiStyleStore({
|
||||
onLocalStyleChange: mapStyle => this.onStyleChanged(mapStyle, false)
|
||||
})
|
||||
|
||||
this.styleStore.supported(isSupported => {
|
||||
if(!isSupported) {
|
||||
@@ -76,11 +78,11 @@ export default class App extends React.Component {
|
||||
this.styleStore.save(snapshotStyle)
|
||||
}
|
||||
|
||||
onStyleChanged(newStyle) {
|
||||
onStyleChanged(newStyle, save=true) {
|
||||
const errors = validateStyleMin(newStyle, GlSpec)
|
||||
if(errors.length === 0) {
|
||||
this.revisionStore.addRevision(newStyle)
|
||||
this.saveStyle(newStyle)
|
||||
if(save) this.saveStyle(newStyle)
|
||||
this.setState({
|
||||
mapStyle: newStyle,
|
||||
errors: [],
|
||||
|
||||
@@ -28,6 +28,7 @@ export default class MapboxGlMap extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
MapboxGl.accessToken = props.accessToken
|
||||
this.state = {
|
||||
map: null,
|
||||
isPopupOpen: false,
|
||||
@@ -37,6 +38,8 @@ export default class MapboxGlMap extends React.Component {
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
MapboxGl.accessToken = nextProps.accessToken
|
||||
|
||||
if(!this.state.map) return
|
||||
|
||||
//Mapbox GL now does diffing natively so we don't need to calculate
|
||||
@@ -45,8 +48,6 @@ export default class MapboxGlMap extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
MapboxGl.accessToken = this.props.accessToken
|
||||
|
||||
const map = new MapboxGl.Map({
|
||||
container: this.container,
|
||||
style: this.props.mapStyle,
|
||||
|
||||
Reference in New Issue
Block a user