Skip to content

Commit ebdd0e1

Browse files
authored
Merge pull request #61 from PnEcrins/add-delay-between-tiles-download
add delay between tiles downlaod
2 parents 72e7b64 + 45523c9 commit ebdd0e1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

front-end/src/app/services/offline.service.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,22 @@ export class OfflineService {
160160
}
161161

162162
const tilesToDownload = [];
163+
let delay = 0;
163164
for (let index = 0; index < tilesToStore.length; index++) {
164165
if (
165166
!(await leafletOffline.default.getBlobByKey(tilesToStore[index].key))
166167
) {
167168
tilesToDownload.push(
168-
leafletOffline.default
169-
.downloadTile(tilesToStore[index].url)
170-
.catch(() => null),
169+
new Promise((resolve) =>
170+
setTimeout(() => {
171+
return leafletOffline.default
172+
.downloadTile(tilesToStore[index].url)
173+
.then((tile) => resolve(tile))
174+
.catch(() => resolve(null));
175+
}, delay),
176+
),
171177
);
178+
delay += 20;
172179
} else {
173180
tilesToDownload.push(new Promise((resolve) => resolve(null)));
174181
}

0 commit comments

Comments
 (0)