Skip to content
Back to skills

Maplibre Gl Js Knowledge Patch

ASecurity

MapLibre GL JS

  • 25 stars
  • 0 votes
  • 0 copies
  • 18 views
  • Added September 5, 2026
developmenttypescriptrustgoexpressapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill maplibre-gl-js-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Maplibre Gl Js Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Maplibre Gl Js Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-maplibre-gl-js-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-maplibre-gl-js-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: maplibre-gl-js-knowledge-patch
description: MapLibre GL JS
version: "6.20.0"
license: MIT
metadata:
  author: Nevaberry
---


# MapLibre GL JS knowledge patch

Load this skill when migrating MapLibre GL JS integrations or working on its
workers, events, sources, styles, camera, terrain, and map UI. The topic
references contain the detailed API changes, examples, and compatibility fixes.

## Reference index

| Reference | Topics |
| --- | --- |
| [Packaging and runtime](references/packaging-and-runtime.md) | ESM imports, worker deployment, CSP, runtime targets, WebGL startup, render clock |
| [Events, types, and errors](references/events-types-and-errors.md) | Subscriptions, event classes, TypeScript migrations, lifecycle events, validation |
| [Sources, tiles, and requests](references/sources-tiles-and-requests.md) | GeoJSON updates and clusters, MLT, overscaling, sparse tiles, protocols, image and DEM sources |
| [Styles, projections, and rendering](references/styles-projections-and-rendering.md) | Missing images, global state, expressions, custom layers, projections, opacity, fonts and glyphs |
| [Camera, globe, and location](references/camera-globe-and-location.md) | Bounds, padding, gestures, terrain elevation, screen coordinates, feature queries |
| [Controls, markers, and UI](references/controls-markers-and-ui.md) | Geolocation, marker accessibility, popups, canvas sizing, attribution, Trusted Types |

## Breaking changes and deprecations

### ESM imports and worker deployment

In v6, the package ships `maplibre-gl.mjs` and drops the `maplibre-gl.js` and
`maplibre-gl-csp.js` UMD bundles. Use named or namespace imports; direct browser
imports need a `<script type="module">`.

```js
import * as maplibregl from 'maplibre-gl';
```

Use an explicit major version in CDN imports, such as
`maplibre-gl@^6.0.0/dist/maplibre-gl.mjs`. An unversioned v5 script URL or one
using `@latest` can return a 404 and leave the map blank when it resolves to v6.

In a bundled app, call `setWorkerUrl()` once before creating maps, pointing to
the emitted or self-hosted `maplibre-gl-worker.mjs` file.

```js
import {setWorkerUrl} from 'maplibre-gl';

setWorkerUrl('/assets/maplibre-gl-worker.mjs');
```

For a direct worker URL, allow that URL in `worker-src` and drop the old UMD
`blob:` allowance. A browser import from a cross-origin CDN starts the worker
from a same-origin Blob URL and needs `blob:` in `worker-src`. Keep `data:` and
`blob:` in `img-src`, including with a self-hosted worker.

From 6.13.0, the worker bundle is self-contained and its default URL includes
a versioned `v` query parameter. Remove `maplibre-gl-shared.mjs` and
`maplibre-gl-shared-dev.mjs` from deployment copy steps when upgrading to
6.13.0 or later: both are empty and deprecated, with removal planned for the
next major version. Earlier shared-chunk deployment guidance is in the
packaging reference.

### Runtime and WebGL startup

The v6 build targets ES2022. Transpile the dependency or update affected tooling
if supporting older runtimes or tooling. Map creation requires WebGL 2.
From 6.7.0, failure to create a WebGL 2 context makes the `Map` constructor
throw `GPUInitializationError` synchronously; wrap construction in `try`/`catch`.

### Listener subscriptions and event types

`map.on()` returns a `Subscription`. Register each listener in a separate call
and use the returned subscription's `unsubscribe()` to remove it.

```js
const subscription = map.on('moveend', onMoveEnd);
map.on('zoomend', onZoomEnd);
subscription.unsubscribe();
```

In v6, map events are class instances. Use `MapBoxZoomEvent` instead of
`MapLibreZoomEvent`, and `MapSourceDataEvent | MapStyleDataEvent` instead of
`MapDataEvent` for `data`, `dataloading`, and `dataabort`. Check `event.type`
to distinguish variants in shared handlers.
The events reference details typed event maps, custom events, and movement types.

### Changed signatures and defaults

In v6, call `source.setData(data)` with one argument: its `waitForCompletion`
flag was removed, and `setData()` no longer returns the source for chaining.
The source reference preserves the earlier update signatures and examples.

The v6 `zoomLevelsToOverscale` default is `4`, which can change
`queryRenderedFeatures()` results and polygon center label placement. Set
`zoomLevelsToOverscale: undefined` to restore the previous behavior.

Replace direct uses of `map.transform` with public map methods and update code
that relied on the removed `transform.getMatrixForModel()`. `Map` extends
`Evented` directly and forwards its public camera methods to a composed `Camera`.

The paint and layout getters and setters now use actual property types in
TypeScript. Update callers that relied on unrestricted names or values.

### Missing images and custom rendering

In v6, `styleimagemissing` only reports a missing image. Register a synchronous
or asynchronous resolver with `map.setMissingStyleImageResolver()`. It receives
the image ID as a string; add the image before an asynchronous resolver settles.

```js
map.setMissingStyleImageResolver(async (id) => {
    const image = await loadImageForId(id);
    map.addImage(id, image);
});
```

Replace `#pragma mapbox` with `#pragma maplibre` in custom shaders using those
directives. Icon offsets no longer scale with icon size; check styles combining
`icon-offset` and `icon-size`.

### Text shaping and drag rotation migrations

From 6.9.0, Arabic and Hebrew labels render without an RTL text plugin.
`setRTLTextPlugin()` and `getRTLTextPluginStatus()` are deprecated; shaping also
improves for complex scripts such as Devanagari, Khmer, and Burmese.

In 6.15.0, replace deprecated `aroundCenter` with
`dragRotate: {around: 'center', movement: 'circular'}`. Use `movement: 'linear'`
for linear drag motion or `dragRotate: {around: 'pointer'}` to rotate and tilt
around the point under the pointer.

## Source updates and tile loading

Set `encoding: 'mlt'` on a vector source using MapLibre Tiles encoding.
From 6.16.0, MLT requests include an `Accept` header based on client MLT capabilities.

In 6.17.0, the experimental vector source option `sparse: true` fills missing
tiles by slicing an ancestor tile.

From 6.12.0, `setData()` supersedes pending results from earlier URL loads and
`updateData()` calls; removing a source discards its waiting updates. From
6.16.0, re-adding a feature in a later `updateData()` call prevents an earlier
queued edit to that feature from carrying over.

`GeoJSONSource.getClusterOptions()` returns `cluster`, `clusterMaxZoom`, and
`clusterRadius`. From 6.20.0, clusters at the antimeridian are drawn and counted
once. See the source reference for promoted IDs and cluster refresh behavior.

Pass `{image}` to `ImageSource.updateImage()` to replace the source image without
a network request. The image can be an `HTMLImageElement`, `HTMLCanvasElement`,
`ImageBitmap`, or `ImageData`.
An image source can omit `url` to start empty and be populated with `updateImage()`.
Experimental `ImageSource.setWarp()` accepts `'auto'`, `'perspective'`, or `'flat'`.

## Styling, global state, and text

### Opacity, blend modes, and feature expressions

`fill-layer-opacity` and `line-layer-opacity` apply opacity to the composited
layer. Use `line-layer-opacity` to keep overlapping lines from darkening at
intersections. Overlapping strokes still compound `line-opacity` and alpha in
`line-color`; the prerelease change to `line-opacity` was reverted for 6.0.0.

`fill-layer-blend`, `line-layer-blend`, and `raster-layer-blend` control blending
with layers below. Version 6.20.0 completes W3C blend mode support and lets
`fill-extrusion-opacity` use data expressions for per-feature opacity.

`line-dasharray` can select dash patterns from feature properties. Wrap arrays
returned by `match` in `literal`. `line-cap`, `line-miter-limit`, and
`line-round-limit` also accept per-feature expressions.

Styles accept CSS `oklab()` and `oklch()` colors. Use `interpolate-oklab` or
`interpolate-oklch` for interpolation in the corresponding color space.

### Global state and font configuration

Supported layout properties, `layout.visibility`, `sky`, `light`, and
`projection.type` can read `global-state`. From 6.14.0, pass `globalState` when
constructing a map or setting its style to override defaults for supplied keys.
Transitionable paint, light, and sky properties reading `global-state` animate
from their prior value when the state changes.

Configure complex-script fonts through `font-faces`; read or update them with
`map.getFontFaces()` and `map.setFontFaces()`. A style without a root `glyphs`
URL renders locally and treats `text-font` as a fallback list. With a glyph URL,
a missing glyph file or character also triggers a local rendering attempt.

## Camera, terrain, and map UI

`map.calculateAnchoredCameraOptions()` computes options that place a geographic
location at a chosen screen position while leaving the current view in place.
Use `absolutePadding: true` with `cameraForBounds()` or `fitBounds()` to treat
the supplied `padding` as the total persistent padding.

On the globe, `map.unproject()` clamps points beyond the visible globe to the
horizon. From 6.9.1, `map.project()` places locations behind the camera outside
the viewport, also moving their DOM markers and popups off-screen.

`map.queryTerrainElevation(lngLat)` returns actual terrain altitude. Subtract
the altitude at a reference point for relative height. With terrain enabled,
`map.project()` and `map.queryTerrainElevation()` use elevations consistent
with the rendered terrain surface.

The experimental `CustomLayerInterface.renderToTerrainTile` hook drapes custom
drawing over terrain; `terrainTileRevision` signals drawing changes. The
`prerender` options expose `renderTerrainHeightMap` for placing objects on terrain
on the GPU. Experimental `addProjection()` and `removeProjection()` manage
custom planar coordinate reference systems with their own quad tile grids.

Use `new GeolocateControl({trackUserLocation: true, zoomToUserAccuracy: false})`
to follow position updates without adjusting zoom to reported accuracy.
`outofmaxbounds` requires `trackUserLocation: true`.

Default draggable markers support keyboard focus: arrow keys move one pixel,
or ten with Shift. Applications manage focus and keyboard interaction for custom
marker elements. Popup `padding` keeps popups away from map-container edges.

Attribution sanitization preserves only allowed HTML tags and attributes, so
previously rendered custom markup can be stripped. Use `setTrustedTypesPolicy`
to configure the library's policy on pages enforcing Trusted Types.

Files in this skill

  • SKILL.md7.5 KB
  • coverage.json1.1 KB
  • references/camera-globe-and-location.md2.3 KB
  • references/controls-markers-and-ui.md1.6 KB
  • references/events-types-and-errors.md2.3 KB
  • references/packaging-and-runtime.md3.2 KB
  • references/sources-tiles-and-requests.md3.7 KB
  • references/styles-projections-and-rendering.md4.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.