Some refactoring
This commit is contained in:
parent
47f77c2819
commit
a151b73d03
@ -261,18 +261,14 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
||||
this.updateLayers(this.itemLayers);
|
||||
}
|
||||
|
||||
updateLayers(itemLayers: IItemLayer[]) {
|
||||
if (itemLayers) {
|
||||
addOrUpdateOlLayer(itemLayer:IItemLayer,index:number):Layer {
|
||||
var olLayers = this.instance.getLayers();
|
||||
itemLayers.forEach((itemLayer, index) => {
|
||||
|
||||
var layer = itemLayer.layer;
|
||||
let olIndex = olLayers.getArray().indexOf(layer);
|
||||
if (olIndex < 0) {
|
||||
// New layer: we add it to the map
|
||||
layer = this.createLayer(itemLayer);
|
||||
if (layer) {
|
||||
itemLayer.layer = layer;
|
||||
olLayers.insertAt(index, layer);
|
||||
}
|
||||
} else if (index !== olIndex) {
|
||||
@ -280,7 +276,16 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
||||
olLayers.removeAt(olIndex);
|
||||
olLayers.insertAt(index, layer);
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
|
||||
updateLayers(itemLayers: IItemLayer[]) {
|
||||
if (itemLayers) {
|
||||
var olLayers = this.instance.getLayers();
|
||||
itemLayers.forEach((itemLayer, index) => {
|
||||
var layer = this.addOrUpdateOlLayer(itemLayer,index);
|
||||
if(layer) {
|
||||
itemLayer.layer = layer;
|
||||
layer.setOpacity(itemLayer.opacity);
|
||||
layer.setVisible(itemLayer.visible);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user