Skip to content

Commit 6606746

Browse files
committed
work on web page
1 parent c9d542b commit 6606746

2 files changed

Lines changed: 57 additions & 11 deletions

File tree

website/_assets/app.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@ class BuildsInfo extends HTMLElement {
2020
get fake() {
2121
return this.hasAttribute("fake");
2222
}
23+
get url() {
24+
return this.getAttribute("url") ?? location.origin;
25+
}
2326

2427
async getMetadata() {
2528
if (this.fake) return BuildsInfo.fakeInfo;
2629

27-
const res = await fetch(this.endpoint);
30+
const res = await fetch(this.getUrl(this.endpoint));
2831
return res.ok ? res.json() : null;
2932
}
3033

34+
getUrl(input) {
35+
return new URL(input, this.url).toString();
36+
}
37+
3138
async render() {
3239
const data = await this.getMetadata();
3340
if (!data) {
@@ -36,12 +43,12 @@ class BuildsInfo extends HTMLElement {
3643
}
3744

3845
const tileAnchor = (name) => {
39-
return `<a href="/tiles/${name}" download="${name}.json">${name}</a>`;
46+
return `<a href="${this.getUrl(name)}" download="${name}">${name}</a>`;
4047
};
4148

4249
const metaAnchor = (pmtiles) => {
4350
const name = pmtiles.replace(/\.pmtiles$/, "");
44-
return `<a href="/tiles/${name}.json" download="${name}.json">metadata</a>`;
51+
return `<a href="${this.getUrl(name)}.json" download="${name}.json">metadata</a>`;
4552
};
4653

4754
const builds = data.targets.map(
@@ -55,20 +62,38 @@ class BuildsInfo extends HTMLElement {
5562
</li>`,
5663
);
5764

58-
const debug = [
59-
`endpoint: ${this.endpoint}`,
60-
`version: ${data.meta.name}/${data.meta.version}`,
61-
];
65+
// const debug = [
66+
// `endpoint: ${this.endpoint}`,
67+
// `version: ${data.meta.name}/${data.meta.version}`,
68+
// ];
69+
70+
const debug = {
71+
element: {
72+
endpoint: this.endpoint,
73+
url: this.url,
74+
fake: this.fake,
75+
},
76+
data,
77+
};
78+
79+
const format = new Intl.DateTimeFormat(undefined, {
80+
dateStyle: "medium",
81+
timeStyle: "medium",
82+
});
83+
const updated = format.format(new Date(data.date));
6284

6385
this.classList.add("flow");
6486

6587
this.innerHTML = `
6688
<ul>
6789
${builds.join("\n")}
6890
</ul>
91+
<p>
92+
Last updated: ${updated}
93+
</p>
6994
<details>
7095
<summary>debug</summary>
71-
<pre>${debug.join("\n")}</pre>
96+
<pre>${JSON.stringify(debug, null, 2)}</pre>
7297
</details>
7398
`;
7499
}

website/index.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,37 @@ There is a brief description of the format and a guide for using them.
99

1010
## about
1111

12-
> TODO: ...
12+
This site contains information about using Open Lab's [PMTiles](https://github.com/protomaps/PMTiles) in your app's maps.
13+
PMTiles is a binary format that contains vector-based tiles for client-side maps, generated from [OpenStreetMap](https://www.openstreetmap.org/about).
14+
That means you can style your maps however you like and do not have to rely on a third party like Google Maps or MapBox.
15+
16+
Internally, the PMTiles format works on [HTTP range requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Range_requests)
17+
so the client only requests the specific tiles in needs and the correct resolutions.
18+
19+
This website documents the tilesets that are available and when they were last updated.
1320

1421
## install
1522

1623
> TODO: ...
1724
25+
- [docs.protomaps.com/pmtiles/maplibre](https://docs.protomaps.com/pmtiles/maplibre)
26+
1827
## cli
1928

20-
> TODO: ...
29+
The other part of this website is a CLI that is used to fetch the generated tiles from [ProtoMaps](https://docs.protomaps.com/basemaps/downloads).
30+
It's `run` command does the following:
31+
32+
1. Connects to the S3 bucket, where the tiles will be uploaded too
33+
2. Reads in the configuration that tells it what tilesets to create with bounding boxes
34+
3. It loads the protomaps build.json file to see what downloads are available.
35+
4. For each target:
36+
5. It uses the `pmtiles` binary to download & extract the boundary box into a new binary
37+
6. It uploads that file to the S3 bucket as `{target}.pmtiles`
38+
7. It also uploads a JSON metadata file containing information about the download as `{target}.json`
39+
8. Finally, it uploads a `_metadata.json` file with information about all the downloads.
2140

2241
## tiles
2342

24-
<builds-info></builds-info>
43+
Copy the URLs below to link them into your app.
44+
45+
<builds-info url="https://maps.openlab.dev/tiles/"></builds-info>

0 commit comments

Comments
 (0)