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';
77
88// All options (except for 'is') follow the OpenLayers options for the respective source class.
99// 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
1013const BASEMAPS = {
1114 earth : [
1215 {
Original file line number Diff line number Diff line change @@ -140,11 +140,16 @@ export default {
140140 import ( `ol/source/${ options . is } .js` ) ,
141141 import ( `ol/layer/${ layerClassName } .js` )
142142 ] ) ;
143- return new layerCls ( {
144- source : new sourceCls ( options ) ,
143+ const source = new sourceCls ( options ) ;
144+ const layer = new layerCls ( {
145+ source,
145146 title : options . title ,
146147 base : true
147148 } ) ;
149+ if ( options . layerCreated ) {
150+ return await options . layerCreated ( layer , source ) ;
151+ }
152+ return layer ;
148153 } catch ( error ) {
149154 console . error ( `Failed to load basemap source for ${ options . is } ` , error ) ;
150155 return null ;
You can’t perform that action at this time.
0 commit comments