More refactoring
This commit is contained in:
parent
a151b73d03
commit
da1c9c3fe2
@ -226,12 +226,6 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
||||
return layer;
|
||||
}
|
||||
|
||||
createTemporalLayer(item:IItem,itemLayer:IItemLayer):Layer {
|
||||
let i = itemLayer as ITemporalItemLayer;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
createLayer(itemLayer: IItemLayer): Layer {
|
||||
var layer: Layer = null;
|
||||
var layerIndex = -1;
|
||||
@ -241,11 +235,6 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
||||
layer = this.createShapeLayer(itemLayer.item,itemLayer);
|
||||
} else if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.layer') {
|
||||
layer = this.createExternalLayer(itemLayer.item,itemLayer);
|
||||
} else if (itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') {
|
||||
var i = itemLayer as ITemporalItemLayer;
|
||||
if(i.selectedItem) {
|
||||
layer = this.createLayer( new ItemLayer(i.selectedItem) );
|
||||
}
|
||||
}
|
||||
if (layer) {
|
||||
let geometry = new GeoJSON().readGeometry(itemLayer.item.geometry);
|
||||
@ -276,23 +265,35 @@ 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);
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
|
||||
updateLayers(itemLayers: IItemLayer[]) {
|
||||
let newLayers: IItemLayer[] = [];
|
||||
if (itemLayers) {
|
||||
itemLayers.forEach((itemLayer, index) => {
|
||||
if(itemLayer.item.itemType == 'vnd.farmmaps.itemtype.temporal') {
|
||||
let il = itemLayer as ITemporalItemLayer;
|
||||
let previousLayer = this.addOrUpdateOlLayer(il.previousItemLayer,newLayers.length);
|
||||
if(previousLayer) newLayers.push(previousLayer);
|
||||
let selectedLayer = this.addOrUpdateOlLayer(il.selectedItemLayer,newLayers.length);
|
||||
if(selectedLayer) newLayers.push(selectedLayer);
|
||||
let nextLayer = this.addOrUpdateOlLayer(il.nextItemLayer,newLayers.length);
|
||||
if(selectedLayer) newLayers.push(nextLayer);
|
||||
} else {
|
||||
let layer = this.addOrUpdateOlLayer(itemLayer,newLayers.length);
|
||||
if(layer) newLayers.push(layer);
|
||||
}
|
||||
});
|
||||
// Remove the layers that have disapeared from childrenLayers
|
||||
if (olLayers.getLength() > itemLayers.length) {
|
||||
for (let i = itemLayers.length; i < olLayers.getLength(); i++) {
|
||||
var olLayers = this.instance.getLayers();
|
||||
if (olLayers.getLength() > newLayers.length) {
|
||||
for (let i = newLayers.length; i < olLayers.getLength(); i++) {
|
||||
olLayers.removeAt(i);
|
||||
}
|
||||
}
|
||||
|
@ -26,21 +26,17 @@ export class ItemLayer implements IItemLayer {
|
||||
}
|
||||
|
||||
export interface ITemporalItemLayer extends IItemLayer {
|
||||
previousLayer: Layer
|
||||
nextLayer: Layer
|
||||
previousItemLayer: IItemLayer,
|
||||
selectedItemLayer: IItemLayer,
|
||||
nextItemLayer: IItemLayer,
|
||||
temporalItems: IItem[],
|
||||
previousItem: IItem,
|
||||
selectedItem: IItem,
|
||||
nextItem:IItem
|
||||
}
|
||||
|
||||
export class TemporalItemLayer extends ItemLayer implements ITemporalItemLayer {
|
||||
public previousLayer:Layer = null;
|
||||
public nextLayer:Layer = null;
|
||||
public previousItemLayer:IItemLayer = null;
|
||||
public selectedItemLayer:IItemLayer =null;
|
||||
public nextItemLayer:IItemLayer = null;
|
||||
public temporalItems:IItem[] = [];
|
||||
public previousItem:IItem = null;
|
||||
public selectedItem:IItem =null;
|
||||
public nextItem:IItem = null;
|
||||
|
||||
constructor(item:IItem) {
|
||||
super(item)
|
||||
|
@ -181,9 +181,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
let a = action as mapActions.SelectTemporalItemsSuccess;
|
||||
let selectedItemLayer=tassign(state.selectedItemLayer) as TemporalItemLayer;
|
||||
selectedItemLayer.temporalItems = a.temporalItems;
|
||||
selectedItemLayer.selectedItem = a.temporalItems.length>0?a.temporalItems[a.temporalItems.length-1]:null;
|
||||
selectedItemLayer.previousItem = a.temporalItems.length>1?a.temporalItems[a.temporalItems.length-2]:null;
|
||||
selectedItemLayer.nextItem = null;
|
||||
selectedItemLayer.selectedItemLayer = a.temporalItems.length>0?new ItemLayer(a.temporalItems[a.temporalItems.length-1]):null;
|
||||
selectedItemLayer.previousItemLayer = a.temporalItems.length>1?new ItemLayer(a.temporalItems[a.temporalItems.length-2]):null;
|
||||
selectedItemLayer.nextItemLayer = null;
|
||||
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,selectedItemLayer as ItemLayer)});
|
||||
}
|
||||
case mapActions.STARTSEARCH: {
|
||||
|
Loading…
Reference in New Issue
Block a user