@@ -363,41 +363,39 @@ export default class App extends React.Component<any, AppState> {
363
363
}
364
364
}
365
365
366
+ this . onStyleChanged ( changedStyle )
367
+ }
368
+
369
+ onStyleChanged = ( newStyle : StyleSpecification & { id : string } , opts : OnStyleChangedOpts = { } ) => {
370
+ opts = {
371
+ save : true ,
372
+ addRevision : true ,
373
+ initialLoad : false ,
374
+ ...opts ,
375
+ } ;
366
376
367
377
// For the style object, find the urls that has "{key}" and insert the correct API keys
368
378
// Without this, going from e.g. MapTiler to OpenLayers and back will lose the maptlier key.
369
379
370
- if ( changedStyle . glyphs && typeof changedStyle . glyphs === 'string' ) {
371
- changedStyle . glyphs = setFetchAccessToken ( changedStyle . glyphs , changedStyle ) ;
380
+ if ( newStyle . glyphs && typeof newStyle . glyphs === 'string' ) {
381
+ newStyle . glyphs = setFetchAccessToken ( newStyle . glyphs , newStyle ) ;
372
382
}
373
383
374
- if ( changedStyle . sprite && typeof changedStyle . sprite === 'string' ) {
375
- changedStyle . sprite = setFetchAccessToken ( changedStyle . sprite , changedStyle ) ;
384
+ if ( newStyle . sprite && typeof newStyle . sprite === 'string' ) {
385
+ newStyle . sprite = setFetchAccessToken ( newStyle . sprite , newStyle ) ;
376
386
}
377
387
378
- for ( const [ _sourceId , source ] of Object . entries ( changedStyle . sources ) ) {
388
+ for ( const [ _sourceId , source ] of Object . entries ( newStyle . sources ) ) {
379
389
if ( source && 'url' in source && typeof source . url === 'string' ) {
380
- source . url = setFetchAccessToken ( source . url , changedStyle ) ;
390
+ source . url = setFetchAccessToken ( source . url , newStyle ) ;
381
391
}
382
392
}
383
393
384
- this . onStyleChanged ( changedStyle )
385
- }
386
-
387
- onStyleChanged = ( newStyle : StyleSpecification & { id : string } , opts : OnStyleChangedOpts = { } ) => {
388
- opts = {
389
- save : true ,
390
- addRevision : true ,
391
- initialLoad : false ,
392
- ...opts ,
393
- } ;
394
394
395
395
if ( opts . initialLoad ) {
396
396
this . getInitialStateFromUrl ( newStyle ) ;
397
397
}
398
398
399
-
400
-
401
399
const errors : ValidationError [ ] = validateStyleMin ( newStyle ) || [ ] ;
402
400
403
401
// The validate function doesn't give us errors for duplicate error with
0 commit comments