Refactor style cache
This commit is contained in:
@@ -19,10 +19,15 @@ import {commonReducers} from '@farmmaps/common';
|
||||
|
||||
import {commonActions} from '@farmmaps/common';
|
||||
|
||||
import { IListItem, IItem } from '@farmmaps/common';
|
||||
import { IItem } from '@farmmaps/common';
|
||||
import { FolderService, ItemService } from '@farmmaps/common';
|
||||
import { tassign } from 'tassign';
|
||||
|
||||
import {FeatureIconService} from '../services/feature-icon.service';
|
||||
|
||||
import * as style from 'ol/style';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class MapEffects {
|
||||
private _geojsonFormat: GeoJSON;
|
||||
@@ -44,10 +49,41 @@ export class MapEffects {
|
||||
ofType(mapActions.INIT),
|
||||
withLatestFrom(this.store$.select(commonReducers.selectGetRootItems)),
|
||||
switchMap(([action, rootItems]) => {
|
||||
let actions=[];
|
||||
for (let rootItem of rootItems) {
|
||||
if (rootItem.itemType == "UPLOADS_FOLDER") return of(new mapActions.SetParent(rootItem.code));
|
||||
if (rootItem.itemType == "UPLOADS_FOLDER") actions.push(new mapActions.SetParent(rootItem.code));
|
||||
}
|
||||
return [];
|
||||
// initialize default feature styles
|
||||
actions.push(new mapActions.SetStyle('file',new style.Style({
|
||||
image: new style.Icon({
|
||||
anchor: [0.5, 1],
|
||||
scale: 0.05,
|
||||
src: this.featureIconService$.getIconImageDataUrl("fa fa-file-o")
|
||||
}),
|
||||
stroke: new style.Stroke({
|
||||
color: 'red',
|
||||
width: 1
|
||||
}),
|
||||
fill: new style.Fill({
|
||||
color: 'rgba(0, 0, 255, 0.1)'
|
||||
})
|
||||
})));
|
||||
actions.push(new mapActions.SetStyle('selected',new style.Style({
|
||||
image: new style.Icon({
|
||||
anchor: [0.5, 1],
|
||||
scale: 0.08,
|
||||
src: this.featureIconService$.getIconImageDataUrl(null)
|
||||
}),
|
||||
stroke: new style.Stroke({
|
||||
color: 'red',
|
||||
width: 3
|
||||
}),
|
||||
fill: new style.Fill({
|
||||
color: 'rgba(0, 0, 255, 0.1)'
|
||||
})
|
||||
})));
|
||||
|
||||
return actions;
|
||||
}
|
||||
));
|
||||
|
||||
@@ -231,7 +267,7 @@ export class MapEffects {
|
||||
return of(newAction);
|
||||
}));
|
||||
|
||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService) {
|
||||
constructor(private actions$: Actions, private store$: Store<mapReducers.State>, private folderService$: FolderService, private itemService$: ItemService,private featureIconService$:FeatureIconService) {
|
||||
this._geojsonFormat = new GeoJSON();
|
||||
this._wktFormat = new WKT();
|
||||
}
|
||||
|
Reference in New Issue
Block a user