geostyler-mapbox-parser is a JavaScript/TypeScript library that provides an implementation for the GeoStyler-Style-Parser interface, specifically for converting between GeoStyler's abstract style representation and Mapbox GL JS style specifications. The current stable version is 6.2.0, with regular updates and new feature releases (e.g., v6.2.0 in late 2025, v6.1.0 and v6.0.0 in 2024). It serves as a critical component in the GeoStyler ecosystem, enabling developers to define styles once and apply them across various mapping libraries. Key differentiators include its adherence to the GeoStyler abstract style format, comprehensive support for Mapbox GL JS style properties, and explicit handling of Mapbox-specific concepts like spritesheets (requiring a companion API endpoint) and source definitions (managed in metadata for data/style separation). The library transitioned to an ESM-only build in v6.0.0, impacting import patterns for consumers.
npm install geostyler-mapbox-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the parser and convert a simple GeoStyler point style object into a Mapbox GL JS style definition asynchronously.
Update import statements to use ES6 `import` syntax. If using CommonJS, configure your bundler (e.g., Webpack, Rollup) to handle ESM or ensure your Node.js environment supports ESM. For browser usage via script tags, access `GeoStylerMapboxParser.MapboxStyleParser`.
Review existing sprite definitions and update them to conform to the `geostyler-style` Sprite object structure.
Ensure all Mapbox style objects passed to the parser include a valid `source` property.
Implement the `/sprites` API endpoint in your application that returns a reference to a single image based on `name` and `baseurl` query parameters.
When reading a style, extract `sources`, `sourceMapping`, and `layerSourceMapping` from `style.metadata['mapbox:ref']` to correctly re-create the layer structure with your map library.
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`) or use a bundler to transpile.
Ensure the library is loaded via a `<script>` tag and then instantiate `new GeoStylerMapboxParser.MapboxStyleParser()`.
Add a `source` property to your Mapbox style input object, even if it's an empty object if no specific source is needed at the style level (though typically a valid source ID is expected).