-
Notifications
You must be signed in to change notification settings - Fork 0
/
export-map-puppeteer.js
41 lines (28 loc) · 1.28 KB
/
export-map-puppeteer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: true,
executablePath: '/usr/bin/chromium'
});
const page = await browser.newPage();
const zoomLevel = 13;
const tilesAroundCenter = 2; // Adjust as needed
const tileSize = 360 / Math.pow(2, zoomLevel);
const tileCount = (2 * tilesAroundCenter) + 1;
const tileIncrement = tileSize * tileCount;
const centerLat = 51.000;
const centerLon = 0.000;
for (let latOffset = -tilesAroundCenter; latOffset <= tilesAroundCenter; latOffset++) {
for (let lonOffset = -tilesAroundCenter; lonOffset <= tilesAroundCenter; lonOffset++) {
const tileLat = centerLat + latOffset * tileIncrement;
const tileLon = centerLon + lonOffset * tileIncrement;
//~ http://ipfs.asycn.io/ipfs/QmZzE8ypb2q9CF93B8gbjif3Qpqhsrh8y5DtgPPwGYTpdP/map_render.html?southWestLat=${tileLat}&southWestLon=${tileLon}°=1
const url = `file:///home/fred/workspace/OSM2IPFS/earth/Umap.html?southWestLat=${tileLat}&southWestLon=${tileLon}°=0.01`;
await page.goto(url);
await page.waitForTimeout(2000);
const fileName = `map_${tileLat.toFixed(6)}_${tileLon.toFixed(6)}.png`;
await page.screenshot({ path: fileName });
}
}
await browser.close();
})();