Fix layer selection
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
This commit is contained in:
@@ -164,8 +164,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
var itemLayer = null;
|
||||
if (a.item && "vnd.farmmaps.itemtype.layer,vnd.farmmaps.itemtype.shape.processed,vnd.farmmaps.itemtype.geotiff.processed".indexOf(a.item.itemType) >=0 ) {
|
||||
itemLayer = new ItemLayer(a.item);
|
||||
itemLayer.layerIndex = a.item.data.layers[0].index;
|
||||
} else if (a.item && a.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
||||
itemLayer = new TemporalItemLayer(a.item);
|
||||
itemLayer = new TemporalItemLayer(a.item);
|
||||
}
|
||||
return tassign(state, {
|
||||
selectedItem: a.item,
|
||||
@@ -180,10 +181,22 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
case mapActions.SELECTTEMPORALITEMSSUCCESS:{
|
||||
let a = action as mapActions.SelectTemporalItemsSuccess;
|
||||
let selectedItemLayer=tassign(state.selectedItemLayer) as TemporalItemLayer;
|
||||
let layerIndex=-1;
|
||||
selectedItemLayer.temporalItems = a.temporalItems;
|
||||
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],0):null;
|
||||
if(a.temporalItems.length>0) {
|
||||
let item = a.temporalItems[a.temporalItems.length-1];
|
||||
layerIndex = item.data.layers[0].index;
|
||||
selectedItemLayer.selectedItemLayer = new ItemLayer(item,1,true,layerIndex);
|
||||
} else {
|
||||
selectedItemLayer.selectedItemLayer = null;
|
||||
}
|
||||
selectedItemLayer.previousItemLayer = a.temporalItems.length>1?new ItemLayer(a.temporalItems[a.temporalItems.length-2],0,true,layerIndex):null;
|
||||
selectedItemLayer.nextItemLayer = null;
|
||||
if(selectedItemLayer.selectedItemLayer) {
|
||||
let layerIndex = selectedItemLayer.selectedItemLayer.item.data.layers[0].index;
|
||||
selectedItemLayer.layerIndex = layerIndex;
|
||||
}
|
||||
|
||||
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,selectedItemLayer as ItemLayer)});
|
||||
}
|
||||
case mapActions.NEXTTEMPORAL: {
|
||||
@@ -194,11 +207,20 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
return state;
|
||||
} else {
|
||||
temporalLayer.previousItemLayer = temporalLayer.selectedItemLayer;
|
||||
if( temporalLayer.previousItemLayer) temporalLayer.previousItemLayer.opacity=0;
|
||||
if( temporalLayer.previousItemLayer) {
|
||||
temporalLayer.previousItemLayer.opacity=0;
|
||||
temporalLayer.previousItemLayer.layerIndex = temporalLayer.layerIndex;
|
||||
}
|
||||
temporalLayer.selectedItemLayer = temporalLayer.nextItemLayer;
|
||||
if( temporalLayer.selectedItemLayer) temporalLayer.selectedItemLayer.opacity=1;
|
||||
temporalLayer.nextItemLayer = index+2 < temporalLayer.temporalItems.length ? new ItemLayer(temporalLayer.temporalItems[index+2],0):null;
|
||||
if( temporalLayer.nextItemLayer) temporalLayer.nextItemLayer.opacity=0;
|
||||
if( temporalLayer.selectedItemLayer) {
|
||||
temporalLayer.selectedItemLayer.opacity=1;
|
||||
temporalLayer.selectedItemLayer.layerIndex=temporalLayer.layerIndex;
|
||||
}
|
||||
temporalLayer.nextItemLayer = index+2 < temporalLayer.temporalItems.length ? new ItemLayer(temporalLayer.temporalItems[index+2],0,true,temporalLayer.layerIndex):null;
|
||||
if( temporalLayer.nextItemLayer) {
|
||||
temporalLayer.nextItemLayer.opacity=0;
|
||||
temporalLayer.nextItemLayer.layerIndex = temporalLayer.layerIndex;
|
||||
}
|
||||
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,temporalLayer as ItemLayer)});
|
||||
}
|
||||
} else {
|
||||
@@ -213,11 +235,20 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
return state;
|
||||
} else {
|
||||
temporalLayer.nextItemLayer = temporalLayer.selectedItemLayer;
|
||||
if( temporalLayer.nextItemLayer) temporalLayer.nextItemLayer.opacity=0;
|
||||
temporalLayer.selectedItemLayer = temporalLayer.previousItemLayer;
|
||||
if( temporalLayer.selectedItemLayer) temporalLayer.selectedItemLayer.opacity=1;
|
||||
temporalLayer.previousItemLayer = index-2 >=0? new ItemLayer(temporalLayer.temporalItems[index-2],0):null;
|
||||
if( temporalLayer.previousItemLayer) temporalLayer.previousItemLayer.opacity=0;
|
||||
if( temporalLayer.nextItemLayer) {
|
||||
temporalLayer.nextItemLayer.opacity=0;
|
||||
temporalLayer.nextItemLayer.layerIndex = temporalLayer.layerIndex;
|
||||
}
|
||||
temporalLayer.selectedItemLayer = temporalLayer.previousItemLayer;
|
||||
if( temporalLayer.selectedItemLayer) {
|
||||
temporalLayer.selectedItemLayer.opacity=1;
|
||||
temporalLayer.selectedItemLayer.layerIndex = temporalLayer.layerIndex;
|
||||
}
|
||||
temporalLayer.previousItemLayer = index-2 >=0? new ItemLayer(temporalLayer.temporalItems[index-2],0,true,temporalLayer.layerIndex):null;
|
||||
if( temporalLayer.previousItemLayer) {
|
||||
temporalLayer.previousItemLayer.opacity=0;
|
||||
temporalLayer.previousItemLayer.layerIndex = temporalLayer.layerIndex;
|
||||
}
|
||||
return tassign(state,{selectedItemLayer:tassign(state.selectedItemLayer,temporalLayer as ItemLayer)});
|
||||
}
|
||||
} else {
|
||||
@@ -316,9 +347,36 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
|
||||
}
|
||||
case mapActions.SETLAYERINDEX: {
|
||||
let a = action as mapActions.SetLayerIndex;
|
||||
if (a.itemLayer == null) {
|
||||
var newItemlayer = new ItemLayer(state.selectedItemLayer.item);
|
||||
newItemlayer.layerIndex = a.layerIndex;
|
||||
if (a.itemLayer == null) {
|
||||
if(state.selectedItemLayer.item.itemType == "vnd.farmmaps.itemtype.temporal") {
|
||||
var newItemlayer = tassign(state.selectedItemLayer,{layerIndex:a.layerIndex});
|
||||
let tl = newItemlayer as ITemporalItemLayer;
|
||||
if(tl.previousItemLayer) {
|
||||
let nl = new ItemLayer(tl.previousItemLayer.item);
|
||||
nl.opacity = tl.previousItemLayer.opacity;
|
||||
nl.visible = tl.previousItemLayer.visible;
|
||||
nl.layerIndex = a.layerIndex;
|
||||
tl.previousItemLayer = nl;
|
||||
}
|
||||
if(tl.selectedItemLayer) {
|
||||
let nl = new ItemLayer(tl.selectedItemLayer.item);
|
||||
nl.opacity = tl.selectedItemLayer.opacity;
|
||||
nl.visible = tl.selectedItemLayer.visible;
|
||||
nl.layerIndex = a.layerIndex;
|
||||
tl.selectedItemLayer = nl;
|
||||
}
|
||||
if(tl.nextItemLayer) {
|
||||
let nl = new ItemLayer(tl.nextItemLayer.item);
|
||||
nl.opacity = tl.nextItemLayer.opacity;
|
||||
nl.visible = tl.nextItemLayer.visible;
|
||||
nl.layerIndex = a.layerIndex;
|
||||
tl.nextItemLayer = nl;
|
||||
}
|
||||
} else {
|
||||
var newItemlayer = new ItemLayer(state.selectedItemLayer.item);
|
||||
newItemlayer.layerIndex = a.layerIndex;
|
||||
|
||||
}
|
||||
return tassign(state, { selectedItemLayer: newItemlayer})
|
||||
} else {
|
||||
let newLayers = state.overlayLayers.slice(0);
|
||||
|
Reference in New Issue
Block a user