mirror of
https://github.com/maputnik/editor.git
synced 2026-02-09 06:00:09 +00:00
move to onStyleChanged
This commit is contained in:
@@ -364,24 +364,6 @@ export default class App extends React.Component<any, AppState> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// For the style object, find the urls that has "{key}" and insert the correct API keys
|
||||
// Without this, going from e.g. MapTiler to OpenLayers and back will lose the maptlier key.
|
||||
|
||||
if (changedStyle.glyphs && typeof changedStyle.glyphs === 'string') {
|
||||
changedStyle.glyphs = setFetchAccessToken(changedStyle.glyphs, changedStyle);
|
||||
}
|
||||
|
||||
if (changedStyle.sprite && typeof changedStyle.sprite === 'string') {
|
||||
changedStyle.sprite = setFetchAccessToken(changedStyle.sprite, changedStyle);
|
||||
}
|
||||
|
||||
for (const [_sourceId, source] of Object.entries(changedStyle.sources)) {
|
||||
if (source && 'url' in source && typeof source.url === 'string') {
|
||||
source.url = setFetchAccessToken(source.url, changedStyle);
|
||||
}
|
||||
}
|
||||
|
||||
this.onStyleChanged(changedStyle)
|
||||
}
|
||||
|
||||
@@ -393,11 +375,27 @@ export default class App extends React.Component<any, AppState> {
|
||||
...opts,
|
||||
};
|
||||
|
||||
if (opts.initialLoad) {
|
||||
this.getInitialStateFromUrl(newStyle);
|
||||
// For the style object, find the urls that has "{key}" and insert the correct API keys
|
||||
// Without this, going from e.g. MapTiler to OpenLayers and back will lose the maptlier key.
|
||||
|
||||
if (newStyle.glyphs && typeof newStyle.glyphs === 'string') {
|
||||
newStyle.glyphs = setFetchAccessToken(newStyle.glyphs, newStyle);
|
||||
}
|
||||
|
||||
if (newStyle.sprite && typeof newStyle.sprite === 'string') {
|
||||
newStyle.sprite = setFetchAccessToken(newStyle.sprite, newStyle);
|
||||
}
|
||||
|
||||
for (const [_sourceId, source] of Object.entries(newStyle.sources)) {
|
||||
if (source && 'url' in source && typeof source.url === 'string') {
|
||||
source.url = setFetchAccessToken(source.url, newStyle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (opts.initialLoad) {
|
||||
this.getInitialStateFromUrl(newStyle);
|
||||
}
|
||||
|
||||
const errors: ValidationError[] = validateStyleMin(newStyle) || [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user