Compare commits

...

2 Commits

Author SHA1 Message Date
Willem Dantuma 79f45631a0 Fix Set style Geometry
FarmMaps.Develop/FarmMapsLib/develop This commit looks good Details
2020-02-13 16:14:18 +01:00
Willem Dantuma 6060a8b86a Use a Style or a Style function as parameter to setStyle action 2020-02-13 16:01:05 +01:00
3 changed files with 15 additions and 10 deletions

View File

@ -207,7 +207,7 @@ export class DoQuery implements Action {
export class SetStyle implements Action {
readonly type = SETSTYLE;
constructor(public itemType:string,public style:Style) { }
constructor(public itemType:string,public style: Style | (Feature)) { }
}
export type Actions = SetMapState

View File

@ -120,8 +120,17 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
key = 'file';
}
}
var styleEntry = this.stylesCache[key];
return styleEntry;
let evaluatedStyle =null;
var styleEntry = this.stylesCache[key];
if(typeof styleEntry === 'function') {
evaluatedStyle = styleEntry(feature);
} else {
evaluatedStyle = styleEntry;
}
if(evaluatedStyle.geometry_ == null) {
evaluatedStyle.setGeometry((feature) => this.geometry(feature));
}
return evaluatedStyle;
});
}
@ -155,11 +164,7 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
let styles = changes["styles"].currentValue;
for (const key in styles) {
if (styles.hasOwnProperty(key)) {
let style = styles[key];
if(style.geometry_ == null) {
style.setGeometry((feature) => this.geometry(feature));
}
this.stylesCache[key]=style;
this.stylesCache[key]=styles[key];
}
}
}

View File

@ -1,5 +1,5 @@
import {Style} from 'ol';
import {Style,Feature} from 'ol';
export interface IStyles{
[id: string]: Style;
[id: string]: Style | (Feature);
};