diff --git a/src/components/App.jsx b/src/components/App.jsx index b4aeeb4..f2b401b 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -11,7 +11,7 @@ import Toolbar from './Toolbar' import AppLayout from './AppLayout' import style from '../libs/style.js' -import { loadDefaultStyle, SettingsStore, StyleStore } from '../libs/stylestore' +import { loadDefaultStyle, StyleStore } from '../libs/stylestore' import { ApiStyleStore } from '../libs/apistore' import { RevisionStore } from '../libs/revisions' import LayerWatcher from '../libs/layerwatcher' @@ -31,9 +31,7 @@ export default class App extends React.Component { this.styleStore.latestStyle(mapStyle => this.onStyleChanged(mapStyle)) }) - this.settingsStore = new SettingsStore() this.state = { - accessToken: this.settingsStore.accessToken, mapStyle: style.emptyStyle, selectedLayerIndex: 0, } @@ -85,11 +83,6 @@ export default class App extends React.Component { this.setState({ mapStyle: activeStyle }) } - onAccessTokenChanged(newToken) { - this.settingsStore.accessToken = newToken - this.setState({ accessToken: newToken }) - } - onLayersChange(changedLayers) { const changedStyle = { ...this.state.mapStyle, @@ -133,9 +126,10 @@ export default class App extends React.Component { } mapRenderer() { + const metadata = this.state.mapStyle.metadata || {} const mapProps = { mapStyle: this.state.mapStyle, - accessToken: this.state.accessToken, + accessToken: metadata['maputnik:access_token'], onDataChange: (e) => { this.layerWatcher.analyzeMap(e.map) }, @@ -146,7 +140,6 @@ export default class App extends React.Component { } } - const metadata = this.state.mapStyle.metadata || {} const renderer = metadata['maputnik:renderer'] || 'mbgljs' // Check if OL3 code has been loaded? diff --git a/src/components/modals/SettingsModal.jsx b/src/components/modals/SettingsModal.jsx index 54fb043..ee0baf8 100644 --- a/src/components/modals/SettingsModal.jsx +++ b/src/components/modals/SettingsModal.jsx @@ -23,18 +23,19 @@ class SettingsModal extends React.Component { this.props.onStyleChanged(changedStyle) } - onRendererChange(renderer) { + onMetadataChange(key, value) { const changedStyle = { ...this.props.mapStyle, metadata: { ...this.props.mapStyle.metadata, - 'maputnik:renderer': renderer, + [key]: value } } this.props.onStyleChanged(changedStyle) } render() { + const metadata = this.props.mapStyle.metadata || {} const inputProps = { } return + + + diff --git a/src/libs/stylestore.js b/src/libs/stylestore.js index a15175b..0413acf 100644 --- a/src/libs/stylestore.js +++ b/src/libs/stylestore.js @@ -61,17 +61,6 @@ function styleKey(styleId) { return [storagePrefix, stylePrefix, styleId].join(":") } -// Store style independent settings -export class SettingsStore { - get accessToken() { - const token = window.localStorage.getItem(storageKeys.accessToken) - return token ? token : "" - } - set accessToken(val) { - window.localStorage.setItem(storageKeys.accessToken, val) - } -} - // Manages many possible styles that are stored in the local storage export class StyleStore { // Tile store will load all items from local storage and