diff --git a/src/components/App.jsx b/src/components/App.jsx index 4eca4c3..cc4498a 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -99,7 +99,9 @@ export default class App extends React.Component { updateFonts(urlTemplate) { const metadata = this.state.mapStyle.metadata || {} const accessToken = metadata['maputnik:openmaptiles_access_token'] || tokens.openmaptiles - downloadGlyphsMetadata(urlTemplate.replace('{key}', accessToken), fonts => { + + let glyphUrl = (typeof urlTemplate === 'string')? urlTemplate.replace('{key}', accessToken): urlTemplate; + downloadGlyphsMetadata(glyphUrl, fonts => { this.setState({ spec: updateRootSpec(this.state.spec, 'glyphs', fonts)}) }) } @@ -111,15 +113,17 @@ export default class App extends React.Component { } onStyleChanged(newStyle, save=true) { - if(newStyle.glyphs !== this.state.mapStyle.glyphs) { - this.updateFonts(newStyle.glyphs) - } - if(newStyle.sprite !== this.state.mapStyle.sprite) { - this.updateIcons(newStyle.sprite) - } const errors = styleSpec.validate(newStyle, styleSpec.latest) if(errors.length === 0) { + + if(newStyle.glyphs !== this.state.mapStyle.glyphs) { + this.updateFonts(newStyle.glyphs) + } + if(newStyle.sprite !== this.state.mapStyle.sprite) { + this.updateIcons(newStyle.sprite) + } + this.revisionStore.addRevision(newStyle) if(save) this.saveStyle(newStyle) this.setState({