File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ const XYZ = 'XYZ';
7
7
8
8
// All options (except for 'is') follow the OpenLayers options for the respective source class.
9
9
// Projections (except for EPSG:3857 and EPSG:4326) must be listed in the `crs` array in the config.js.
10
+ //
11
+ // There's a layerCreated callback that can be used to modify the layer and source after it has been created:
12
+ // async layerCreated(Layer layer, Source source) => Layer
10
13
const BASEMAPS = {
11
14
earth : [
12
15
{
Original file line number Diff line number Diff line change @@ -140,11 +140,16 @@ export default {
140
140
import ( `ol/source/${ options . is } .js` ) ,
141
141
import ( `ol/layer/${ layerClassName } .js` )
142
142
] ) ;
143
- return new layerCls ( {
144
- source : new sourceCls ( options ) ,
143
+ const source = new sourceCls ( options ) ;
144
+ const layer = new layerCls ( {
145
+ source,
145
146
title : options . title ,
146
147
base : true
147
148
} ) ;
149
+ if ( options . layerCreated ) {
150
+ return await options . layerCreated ( layer , source ) ;
151
+ }
152
+ return layer ;
148
153
} catch ( error ) {
149
154
console . error ( `Failed to load basemap source for ${ options . is } ` , error ) ;
150
155
return null ;
You can’t perform that action at this time.
0 commit comments