Skip to content

Commit

Permalink
refactor(Layer): instanciate new Style at Layer instead of at examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff authored and gchoqueux committed Jul 11, 2023
1 parent 08dbd3d commit d26f29e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Layer/ColorLayer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import RasterLayer from 'Layer/RasterLayer';
import { updateLayeredMaterialNodeImagery } from 'Process/LayeredMaterialNodeProcessing';
import { RasterColorTile } from 'Renderer/RasterTile';
import Style from 'Core/Style';
import { deprecatedColorLayerOptions } from 'Core/Deprecated/Undeprecator';

/**
Expand Down Expand Up @@ -84,7 +83,7 @@ class ColorLayer extends RasterLayer {
deprecatedColorLayerOptions(config);
super(id, config);
this.isColorLayer = true;
this.style = new Style(config.style);
this.style = config.style;
this.defineLayerProperty('visible', true);
this.defineLayerProperty('opacity', 1.0);
this.defineLayerProperty('sequence', 0);
Expand Down
4 changes: 4 additions & 0 deletions src/Layer/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { STRATEGY_MIN_NETWORK_TRAFFIC } from 'Layer/LayerUpdateStrategy';
import InfoLayer from 'Layer/InfoLayer';
import Source from 'Source/Source';
import Cache from 'Core/Scheduler/Cache';
import Style from 'Core/Style';

/**
* @property {boolean} isLayer - Used to checkout whether this layer is a Layer.
Expand Down Expand Up @@ -92,6 +93,9 @@ class Layer extends THREE.EventDispatcher {
throw new Error(`Layer ${id} needs Source`);
}
super();
if (config.style && !(config.style instanceof Style)) {
config.style = new Style(config.style);
}
this.isLayer = true;

Object.assign(this, config);
Expand Down

0 comments on commit d26f29e

Please sign in to comment.