Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@maplibre/maplibre-gl-style-spec
Advanced tools
@maplibre/maplibre-gl-style-spec is a package that provides a specification for defining styles for MapLibre GL maps. It allows developers to create, validate, and manipulate map styles in a structured and standardized way.
Style Validation
This feature allows you to validate a MapLibre GL style object against the style specification. The code sample demonstrates how to validate a style and check for any errors.
const { validate } = require('@maplibre/maplibre-gl-style-spec');
const style = {
"version": 8,
"sources": {},
"layers": []
};
const errors = validate(style);
if (errors.length) {
console.error('Style validation errors:', errors);
} else {
console.log('Style is valid!');
}
Style Parsing
This feature allows you to parse a MapLibre GL style object. The code sample shows how to parse a style and log the parsed result.
const { parse } = require('@maplibre/maplibre-gl-style-spec');
const style = {
"version": 8,
"sources": {},
"layers": []
};
const parsedStyle = parse(style);
console.log('Parsed style:', parsedStyle);
Style Generation
This feature allows you to generate a MapLibre GL style object. The code sample demonstrates how to generate a style from a given configuration.
const { generate } = require('@maplibre/maplibre-gl-style-spec');
const style = generate({
version: 8,
sources: {},
layers: []
});
console.log('Generated style:', style);
mapbox-gl-style-spec is a package provided by Mapbox that offers similar functionalities for defining and validating styles for Mapbox GL maps. It is very similar to @maplibre/maplibre-gl-style-spec but is specifically tailored for use with Mapbox GL.
leaflet-styleeditor is a plugin for Leaflet, another popular mapping library. It allows users to interactively edit the styles of Leaflet map layers. Although it provides style editing capabilities, it is designed for use with Leaflet rather than MapLibre GL.
This directory contains code and reference files that define the MapLibre GL style specification and provides some utilities for working with MapLibre styles.
The MapLibre GL style specification and utilities are published as a seperate npm package so that they can be installed without the bulk of GL JS.
npm install @maplibre/maplibre-gl-style-spec
If you install this package globally, you will have access to several CLI tools.
npm install @maplibre/maplibre-gl-style-spec --global
gl-style-migrate
This repo contains scripts for migrating GL styles of any version to the latest version (currently v8). Migrate a style like this:
$ gl-style-migrate bright-v7.json > bright-v8.json
To migrate a file in place, you can use the sponge
utility from the moreutils
package:
$ brew install moreutils
$ gl-style-migrate bright.json | sponge bright.json
gl-style-format
$ gl-style-format style.json
Will format the given style JSON to use standard indentation and sorted object keys.
gl-style-validate
$ gl-style-validate style.json
Will validate the given style JSON and print errors to stdout. Provide a
--json
flag to get JSON output.
18.0.0
FAQs
a specification for maplibre styles
The npm package @maplibre/maplibre-gl-style-spec receives a total of 376,348 weekly downloads. As such, @maplibre/maplibre-gl-style-spec popularity was classified as popular.
We found that @maplibre/maplibre-gl-style-spec demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.