Use a Style or a Style function as parameter to setStyle action

This commit is contained in:
Willem Dantuma 2020-02-13 16:01:05 +01:00
parent 4814b8fbad
commit 6060a8b86a
3 changed files with 7 additions and 4 deletions

View File

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

View File

@ -121,6 +121,9 @@ export class ItemVectorSourceComponent extends SourceVectorComponent implements
} }
} }
var styleEntry = this.stylesCache[key]; var styleEntry = this.stylesCache[key];
if(typeof styleEntry === 'function') {
return styleEntry(feature);
}
return styleEntry; return styleEntry;
}); });
} }

View File

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