diff --git a/.vitepress/config.mts b/.vitepress/config.mts index 35713a4..d671640 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -75,7 +75,7 @@ export default defineConfig({ items: [ { text: "Downloads", link: "/basemaps/downloads" }, { text: "Basemap Layers", link: "/basemaps/layers" }, - { text: "Basemap Themes", link: "/basemaps/themes" }, + { text: "Basemap Flavors", link: "/basemaps/flavors" }, { text: "Basemap Localization", link: "/basemaps/localization" }, { text: "Building Tiles", link: "/basemaps/build" }, { text: "MapLibre GL", link: "/basemaps/maplibre" }, diff --git a/basemaps/downloads.md b/basemaps/downloads.md index 816c436..c810af6 100644 --- a/basemaps/downloads.md +++ b/basemaps/downloads.md @@ -18,7 +18,7 @@ Please note that **URLs may change** and hotlinking to these downloads are disco ## Current Version -The Version 4 Protomaps basemap daily build channel is available at [maps.protomaps.com/builds](https://maps.protomaps.com/builds). This is compatible with `protomaps-themes-base` style v4.0.0 and newer. +The Version 4 Protomaps basemap daily build channel is available at [maps.protomaps.com/builds](https://maps.protomaps.com/builds). This is compatible with `@protomaps/basemaps` style v4.0.0 and newer. [BLAKE3](https://github.com/BLAKE3-team/BLAKE3/releases/) hashes are provided for daily builds. Use `b3sum` to verify the integrity of your downloaded file. diff --git a/basemaps/flavors.md b/basemaps/flavors.md new file mode 100644 index 0000000..48840a2 --- /dev/null +++ b/basemaps/flavors.md @@ -0,0 +1,59 @@ +--- +title: Basemap Flavors +outline: deep +--- + + + +# Basemap Flavors + +These examples use the preferred [MapLibre GL JS](/basemaps/maplibre) library. + +The `Flavor` TypeScript interface is the preferred way to customize the basemap style. See the shape of the interface at the [@protomaps/basemaps TypeScript docs](https://maps.protomaps.com/typedoc/interfaces/Flavor.html). + +A `Flavor` is a plain object of color definitions and optional properties such as font names, landcover shades and POI properties. You can define a `Flavor` yourself for a custom style, similar to a text editor color scheme, or use one of the default named flavors as a base. + +## Default Flavors + +These flavors are included as part of the `@protomaps/basemaps` package. + +### light + +A general-purpose basemap with icons. + + + +### dark + +A general-purpose basemap with icons. + + + +### white + +A flavor for data visualization. + + + +### grayscale + +A flavor for data visualization. + + + +### black + +A flavor for data visualization. + + + +## Overriding Defaults + +Use [ES6 spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) to override any part of the Flavor object. For example, to color buildings red: + +```ts +import { namedFlavor } from "@protomaps/basemaps" +let flavor = {...namedFlavor("light"),buildings:"red") +``` diff --git a/basemaps/maplibre.md b/basemaps/maplibre.md index b5fab0e..1cf7a2a 100644 --- a/basemaps/maplibre.md +++ b/basemaps/maplibre.md @@ -26,7 +26,7 @@ You can view a list of available fonts [in the GitHub repository](https://github ### Sprites -The `sprite` key references a URL specific to one of [the default themes](/basemaps/themes): +The `sprite` key references a URL specific to one of [the default flavors](/basemaps/flavors): ```js sprite: "https://protomaps.github.io/basemaps-assets/sprites/v4/light" @@ -36,20 +36,20 @@ These are required for townspots, highway shields and point of interest icons. ## Loading styles as JSON -Because [MapLibre styles](https://maplibre.org/maplibre-style-spec/) are JSON documents, the simplest way to define a style in your application is with static JSON. You can use the `Get style JSON` feature of [maps.protomaps.com](https://maps.protomaps.com) to generate static JSON for a specific theme and style package version. +Because [MapLibre styles](https://maplibre.org/maplibre-style-spec/) are JSON documents, the simplest way to define a style in your application is with static JSON. You can use the `Get style JSON` feature of [maps.protomaps.com](https://maps.protomaps.com) to generate static JSON for a specific flavor and style package version. ## Creating styles programatically -For more control and less code, you can add use the [`protomaps-themes-base`](https://www.npmjs.com/package/protomaps-themes-base) NPM package as a dependency. +For more control and less code, you can add use the [`@protomaps/basemaps`](https://www.npmjs.com/package/@protomaps/basemaps) NPM package as a dependency. ### Using the npm package ```bash -npm install protomaps-themes-base +npm install @protomaps/basemaps ``` ```js -import layers from 'protomaps-themes-base'; +import { layers, namedFlavor } from '@protomaps/basemaps'; ``` ```js @@ -65,24 +65,26 @@ style: { attribution: 'Protomaps © OpenStreetMap' } }, - layers: layers("protomaps","light") + layers: layers("protomaps",namedFlavor("light"),{lang:"en"}) } ``` -the default export from `protomaps-themes-base` is a function that takes 2 arguments: +the `layers` from `@protomaps/basemaps` is a function that takes 3 arguments: * the source name of the basemap, like `protomaps` in the `sources` example above. -* the [theme](/basemaps/themes), one of `light`, `dark`, `white`, `black`, `grayscale`. +* A [flavor object](/basemaps/flavors); the defaults can be fetched `namedFlavor` with `light`, `dark`, `white`, `black`, `grayscale`. + +* An options object: to display labels. pass a `lang` key. Pass `labelsOnly` to display only labels. ### Using a CDN -Loading the `protomaps-themes-base` package from NPM will define the `protomaps_themes_base` global variable. +Loading the `@protomaps/basemaps` package from NPM will define the `basemaps` global variable. ```html - + ``` ```js -layers: protomaps_themes_base.default("protomaps","light") +layers: basemaps.layers("protomaps",basemaps.namedFlavor("light"),{lang:"en"}) ```` diff --git a/basemaps/themes.md b/basemaps/themes.md deleted file mode 100644 index 1476d97..0000000 --- a/basemaps/themes.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: Basemap Themes -outline: deep ---- - - - -# Basemap Themes - -These examples use the preferred [MapLibre GL JS](/basemaps/maplibre) library. - -## Default Styles - -### light - -A general-purpose basemap style with icons. - - - -### dark - -A general-purpose basemap style with icons. - - - -### white - -A style for data visualization. - - - -### grayscale - -A style for data visualization. - - - -### black - -A style for data visualization. - - \ No newline at end of file diff --git a/components/MaplibreMap.vue b/components/MaplibreMap.vue index 81cd3fa..2ab2461 100644 --- a/components/MaplibreMap.vue +++ b/components/MaplibreMap.vue @@ -1,8 +1,11 @@ - +
@@ -119,7 +119,7 @@ Below is a complete example of a map application that avoids third-party data pr attribution: '© OpenStreetMap' }, }, - layers: protomaps_themes_base.default("protomaps", "light") + layers: basemaps.layers("protomaps", basemaps.namedFlavor("light"), {lang: "en"}) }, }); @@ -129,7 +129,7 @@ Below is a complete example of a map application that avoids third-party data pr * `maplibre-gl.js`, `maplibre-gl.css` - JavaScript and CSS for the MapLibre GL rendering library. * `pmtiles.js` - JavaScript for decoding PMTiles archives in the browser. -* `protomaps-themes-base.js` - JavaScript for creating a MapLibre GL style for a basemap tileset. +* `basemaps.js` - JavaScript for creating a MapLibre GL style for a basemap tileset. * `mapbox-gl-rtl-text.min.js` - MapLibre plugin for supporting right-to-left languages. * `fonts/{fontstack}/{range}.pbf` - Font glyphs for rendering labels, available at [protomaps/basemaps-assets](https://github.com/protomaps/basemaps-assets). -* `sprites/{version/{theme}` - Sprites for basemap icons, available at [protomaps/basemaps-assets](https://github.com/protomaps/basemaps-assets). \ No newline at end of file +* `sprites/{version/{flavor_name}` - Sprites for basemap icons, available at [protomaps/basemaps-assets](https://github.com/protomaps/basemaps-assets). \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8af36a1..5f81e33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "packages": { "": { "dependencies": { + "@protomaps/basemaps": "5.0.0", "maplibre-gl": "^4.7.1", "pmtiles": "^4.1.0", - "protomaps-themes-base": "4.4.0", "vitepress": "^1.5.0" }, "devDependencies": { @@ -801,6 +801,12 @@ "integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==", "license": "ISC" }, + "node_modules/@protomaps/basemaps": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@protomaps/basemaps/-/basemaps-5.0.0.tgz", + "integrity": "sha512-lp+2ktb9gC9jZ/2L2AKvuQt36MNV1lJPOxDHA3IgD09roloxgp6QwXcMyE36ijGKMuKUiYKnmUuT9ouVhNgdLA==", + "license": "BSD-3-Clause" + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.29.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.29.0.tgz", @@ -2329,12 +2335,6 @@ "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz", "integrity": "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw==" }, - "node_modules/protomaps-themes-base": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/protomaps-themes-base/-/protomaps-themes-base-4.4.0.tgz", - "integrity": "sha512-GBJjaQlsotUn4ydTmFw7CoV2tlREoJQRORAsZpxb0g93c0Cge4oSLmgSc3ms84c55Pt7fvNl7/OKU+h9pyjdfQ==", - "license": "BSD-3-Clause" - }, "node_modules/quickselect": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-3.0.0.tgz", diff --git a/package.json b/package.json index 9de164c..abe6d3a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dependencies": { "maplibre-gl": "^4.7.1", "pmtiles": "^4.1.0", - "protomaps-themes-base": "4.4.0", + "@protomaps/basemaps": "5.0.0", "vitepress": "^1.5.0" }, "devDependencies": {