forked from MapComplete/MapComplete
Add caching into local storage for a faster map experience
This commit is contained in:
parent
3a2d654ac3
commit
f33fe081d0
12 changed files with 128 additions and 41 deletions
|
@ -9,15 +9,20 @@ export default class FeatureSourceMerger implements FeatureSource {
|
|||
constructor(sources: FeatureSource[]) {
|
||||
this._sources = sources;
|
||||
const self = this;
|
||||
for (const source of sources) {
|
||||
source.features.addCallback(() => self.Update());
|
||||
for (let i = 0; i < sources.length; i++){
|
||||
let source = sources[i];
|
||||
source.features.addCallback(() => {
|
||||
self.Update();
|
||||
});
|
||||
}
|
||||
this.Update();
|
||||
}
|
||||
|
||||
private Update() {
|
||||
let all = {}; // Mapping 'id' -> {feature, freshness}
|
||||
for (const source of this._sources) {
|
||||
if(source?.features?.data === undefined){
|
||||
console.log("Not defined");
|
||||
continue;
|
||||
}
|
||||
for (const f of source.features.data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue