Skip to content

Commit

Permalink
Introduce spritesheets [#238, #167]
Browse files Browse the repository at this point in the history
* Townspots are rendered as part of the symbol layer and require a theme-specific spritesheet.
* Deployments of basemaps style v3.0.0 requires specifying a sprite MapLibre style property just like fontstacks.
  • Loading branch information
bdon committed May 9, 2024
1 parent ab20125 commit 5b7bf21
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 79 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Styles v3.0.0
------
- introduce dependency on a spritesheet:
- example for `light` theme https://protomaps.github.io/basemaps-assets/sprites/v3/light`
- Change townspots from separate symbol layer to sprite layer
- Style deployments need to depend on the spritesheet assets in addition to fonts.

Styles v2.0.0
------
- Standardize JS package.json on ES6 modules

Tiles v3.5.1
------
- Order landcover by kind consistently [#154]
Expand Down
4 changes: 2 additions & 2 deletions app/src/MapViewComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ function getMaplibreStyle(
style.layers = [];

if (localSprites) {
// style.sprite = `${location.protocol}//${location.host}/${theme}`;
style.sprite = `${location.protocol}//${location.host}/${theme}`;
} else {
// style.sprite = `https://protomaps.github.io/basemaps-assets/sprites/v3/${theme}`;
style.sprite = `https://protomaps.github.io/basemaps-assets/sprites/v3/${theme}`;
}

style.glyphs =
Expand Down
4 changes: 2 additions & 2 deletions styles/package-lock.json

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

2 changes: 1 addition & 1 deletion styles/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "protomaps-themes-base",
"version": "2.0.0",
"version": "3.0.0",
"description": "Protomaps basemap themes for MapLibre GL JS",
"type": "module",
"exports": "./dist/index.js",
Expand Down
78 changes: 4 additions & 74 deletions styles/src/base_layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1692,29 +1692,6 @@ export function labels_layers(source: string, t: Theme): LayerSpecification[] {
"text-halo-width": 2,
},
},
// {
// id: "pois_high_zooms",
// type: "symbol",
// source: source,
// minzoom: 15,
// "source-layer": "pois",
// "filter": ["any", [">=", ["get", "pmap:min_zoom"], 13]],
// layout: {
// "symbol-sort-key": ["get", "pmap:min_zoom"],
// "text-font": ["Noto Sans Regular"],
// "text-field": ["get", "name"],
// "text-size": 11,
// "text-max-width": 9,
// "icon-padding": ["interpolate", ["linear"],
// ["zoom"], 0, 2, 14, 2, 16, 20, 17, 2, 22, 2
// ],
// },
// paint: {
// "text-color": t.subplace_label,
// "text-halo-color": t.subplace_label_halo,
// "text-halo-width": 1.5,
// },
// },
{
id: "physical_point_ocean",
type: "symbol",
Expand Down Expand Up @@ -1824,68 +1801,21 @@ export function labels_layers(source: string, t: Theme): LayerSpecification[] {
],
"text-transform": "uppercase",
},
paint: {
"text-color": t.subplace_label,
"text-halo-color": t.subplace_label_halo,
"text-halo-width": 2.0,
},
},
{
id: "pois_important",
type: "symbol",
source: source,
"source-layer": "pois",
filter: ["any", ["<", ["get", "pmap:min_zoom"], 13]],
layout: {
"symbol-sort-key": ["get", "pmap:min_zoom"],
"text-font": ["Noto Sans Regular"],
"text-field": ["get", "name"],
"text-size": 11,
"text-max-width": 9,
"icon-padding": [
"interpolate",
["linear"],
["zoom"],
0,
2,
14,
2,
16,
20,
17,
2,
22,
2,
],
},
paint: {
"text-color": t.subplace_label,
"text-halo-color": t.subplace_label_halo,
"text-halo-width": 1.5,
},
},
{
id: "places_locality_circle",
type: "circle",
source: source,
"source-layer": "places",
filter: ["==", "pmap:kind", "locality"],
paint: {
"circle-radius": 2,
"circle-stroke-width": 1.5,
"circle-stroke-color": t.city_circle_stroke,
"circle-color": t.city_circle,
"circle-translate": [-6, 0],
},
maxzoom: 8,
},
{
id: "places_locality",
type: "symbol",
source: source,
"source-layer": "places",
filter: ["==", "pmap:kind", "locality"],
layout: {
"icon-image": ["step", ["zoom"], "townspot", 8, ""],
"icon-size": 0.7,
"text-field": "{name}",
"text-font": [
"case",
Expand Down Expand Up @@ -1968,7 +1898,7 @@ export function labels_layers(source: string, t: Theme): LayerSpecification[] {
["linear"],
["zoom"],
0,
2,
0,
8,
4,
10,
Expand All @@ -1979,7 +1909,7 @@ export function labels_layers(source: string, t: Theme): LayerSpecification[] {
2,
],
"text-anchor": ["step", ["zoom"], "left", 8, "center"],
"text-radial-offset": 0.2,
"text-radial-offset": 0.4,
},
paint: {
"text-color": t.city_label,
Expand Down

0 comments on commit 5b7bf21

Please sign in to comment.