Skip to content

Commit

Permalink
set default viewport in style based on region
Browse files Browse the repository at this point in the history
  • Loading branch information
dschep committed Jan 16, 2025
1 parent c3a4753 commit 8160995
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
5 changes: 5 additions & 0 deletions buildStyles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import fs from "fs";
import { writeFile } from "fs/promises";
import i from "protomaps-themes-base";
import { language_script_pairs } from "protomaps-themes-base";
import { viewport } from "@mapbox/geo-viewport";
import { bbox } from "@turf/bbox";

const region = JSON.parse(fs.readFileSync("region.geojson"));

// Determine tile URL
let tileJson;
Expand Down Expand Up @@ -33,6 +37,7 @@ for (const theme of ["light", "dark", "white", "grayscale", "black"]) {
sprite: `https://protomaps.github.io/basemaps-assets/sprites/v4/${theme}`,
glyphs:
"https://protomaps.github.io/basemaps-assets/fonts/{fontstack}/{range}.pbf",
...viewport(bbox(region), [600, 600]),
};

const directory = `dist/styles/${theme}`;
Expand Down
69 changes: 69 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
},
"homepage": "https://github.com/maprva/protomaps-ghpages#readme",
"dependencies": {
"@mapbox/geo-viewport": "^0.5.0",
"@turf/bbox": "^7.2.0",
"protomaps-themes-base": "^4.3.1"
},
"devDependencies": {
Expand Down

0 comments on commit 8160995

Please sign in to comment.