Data and visualization extensions
The optional data and visualization packages extend the core deck.gl runtime without changing its main rendering model. They turn serialized configuration into runtime values, connect CARTO data and map descriptions to deck.gl layers, and add reusable behavior such as filtering, masking, terrain placement, collision control, and path and fill styling.
Extension boundary
The extension boundary separates the core runtime from capabilities that not every application needs. Each package supplies a public entry point and works with core layer contracts, so an application can add one capability without adopting the others. The published CARTO and extensions packages provide both module and CommonJS entry points for different host applications.
Package roles
The three packages address different parts of the visualization path:
| Package | System role | Result for an application |
|---|---|---|
@deck.gl/json | Converts declarative JSON into runtime props and configured objects | A serialized layer or view description can drive a deck.gl visualization |
@deck.gl/carto | Connects CARTO sources, map descriptions, tiles, and styles to deck.gl | CARTO data can become ready-to-render layers and basemaps |
@deck.gl/extensions | Adds reusable capabilities to compatible layers | A layer can gain extra behavior without a new layer type |
These packages are optional. The core runtime still owns layer state, rendering, and interaction after the packages produce layers or layer props.
References: modules/…/package.json• L1-51 modules/…/package.json• L1-80 modules/…/package.json• L1-55
Declarative JSON configuration
The JSON subsystem provides a declarative input path for deck.gl layers, views, and their properties. It resolves names and expressions in a JSON document against application-provided catalogs, then returns values that the normal runtime can use.
Configuration translation
JSONConverter accepts a JSON string or object and walks its values recursively. A configured type becomes a class or React component instance, a configured function reference becomes a function result, and special string forms become accessors, constants, or enumerated values.
The configuration catalogs define what serialized names are allowed to become. This keeps the JSON format separate from the JavaScript objects that execute it and lets a wrapper register its own classes, functions, constants, and enums.
flowchart LR
A[JSON document] --> B[JSON converter]
B --> C[Configured classes and components]
B --> D[Accessors and function results]
B --> E[Constants and enum values]
C --> F[Deck layer or view props]
D --> F
E --> F
F --> G[Core visualization runtime]
The converter supports small expressions for data access. It does not allow function-call syntax in those expressions, which keeps expression evaluation limited to the supplied data rather than arbitrary global behavior.
See the JSON specification for the document forms and value rules.
References: modules/…/json-converter.ts• L15-43 modules/…/json-converter.ts• L89-169 modules/…/json-configuration.ts• L23-45 modules/…/parse-expression-string.ts• L30-63
CARTO data access
The CARTO subsystem connects CARTO data services to deck.gl's layer model. It accepts CARTO source definitions or map descriptions, obtains the data or tile metadata needed by a layer, and exposes the result as deck.gl layer instances. The package supports both module import and CommonJS require use, so the same data path can serve modern and older host applications.
Source and layer flow
The package covers several geospatial source shapes. Query and table sources can feed data-driven layers, while tileset sources support tiled vector, raster, H3, and quadbin views. The package also exposes helpers for CARTO basemap styles and for converting map descriptions into deck.gl basemap and layer properties.
When an application calls fetchMap, the CARTO client returns layer descriptors. The deck.gl wrapper maps each supported descriptor type to a matching layer class, so the result is ready to add to a Deck instance. A lower-level use can keep the descriptors and call LayerFactory when it needs to control layer creation.
Quadbin cells use the same tile-space model as the CARTO tile source. The integration converts a cell into a tile offset and scale, then converts its covered tile area into world bounds or a geographic polygon. This gives tiled analysis layers a consistent cell position when they build clusters or heatmaps.
sequenceDiagram
participant App as Application
participant Carto as CARTO services
participant Integration as CARTO integration
participant Core as Core runtime
App->>Integration: Request map or define source
Integration->>Carto: Fetch map, tiles, or data
Carto-->>Integration: Descriptors, tile metadata, or records
Integration->>Integration: Map data to deck.gl layer types
Integration-->>App: Layer instances and basemap props
App->>Core: Add layers to the visualization
Core-->>App: Rendered CARTO data
The layer family also supports two tiled analysis paths. Cluster layers combine visible H3 or quadbin cells into viewport-aware point summaries. Heatmap layers turn weighted H3 or quadbin cells into a density view with a configurable color range. They normalize cell weights by cell resolution and adjust the displayed maximum as the viewport changes, so density remains comparable across tile levels. These paths preserve the deck.gl layer contract while hiding tile loading and cell aggregation from the application.
Heatmap palettes follow the color value convention used by the active Deck instance. The layer rebuilds its palette when either the colors or that convention changes, so normalized color arrays and byte color arrays produce the same intended visual scale.
Vector tile rendering accepts CARTO's native binary tiles and MVT tiles. Native sources can keep geometry and properties in separate tile requests, while the integration combines them before rendering. Tile decoding can run in workers, and the package keeps a CommonJS decoder path for hosts that cannot use the module-only decoder export.
Vector tile rendering provides a point-label path for primary and secondary labels. It can reserve label space for collision checks while keeping the visible text background separate. In native tile mode, the integration clips geometry sublayers to the tile bounds and passes compatible extensions to those sublayers. Automatic labels are created as a later sublayer when enabled.
See the CARTO integration page for source types, map loading, tile behavior, and the Python CARTO boundary.
References: modules/…/package.json• L26-80 modules/…/build-cjs.mjs• L5-25 modules/…/fetch-map.ts• L25-71 modules/…/quadbin-utils.ts• L10-29 modules/…/vector-tile-layer.ts• L74-95 modules/…/vector-tile-layer.ts• L99-132 modules/…/vector-tile-layer.ts• L164-235 modules/…/cluster-tile-layer.ts• L283-319 modules/…/heatmap-tile-layer.ts• L194-253 modules/…/heatmap-tile-layer.ts• L270-375 modules/…/heatmap-tile-layer.ts• L393-414 modules/…/carto-vector-tile-loader.ts• L32-45 modules/…/cartoVectorTile.ts• L5-8 modules/…/utils.ts• L42-46
Composable layer capabilities
The extensions subsystem lets an application attach a capability to a compatible layer through the layer's extensions property. An extension participates in the layer lifecycle and can add props, shader behavior, GPU work, or a shared effect while the layer keeps its original data and rendering role.
The extension surface has matching shader paths for WebGL and WebGPU. This keeps the same layer-level capability available across the two rendering backends without changing the data contract of the host layer.
Pointer brushing shows or hides objects near the current pointer. Numeric and category filtering applies hard or soft rules to object data and can report how many objects remain visible. Both capabilities add the data needed by the layer and apply the final visibility decision during rendering.
Data filtering can also count the objects that pass its rules. The count is produced by a separate aggregation pass and reported through the layer callback. WebGPU may return it after the draw has finished, so results from an older filter or data state are discarded.
Collision filtering handles overlap between layers that share a collision group. It builds a shared collision map for each group, then lets participating layers use that map during normal drawing and picking. The map is refreshed when the view, layer bounds, loading state, or transitions change.
Path styling supports dashed lines and line offsets on path geometry. It also supports dash treatment for scatterplot outlines and text backgrounds. Path dashes can use width, pixel, meter, or common-space units. Whole-path dash mode keeps the dash phase continuous across rendered segments and needs readable path data or supplied dash metrics. The legacy Fp64Extension adds high-precision projection for supported longitude and latitude layers, but it is deprecated.
Fill styling supports image-atlas patterns and procedural hatch, cross-hatch, and dot patterns. These capabilities leave the underlying layer responsible for its data and geometry.
Procedural fill patterns are described by named JSON-like definitions. The extension validates those definitions, packs them into a GPU-readable pattern description, and evaluates the shapes in the shader. This avoids a required image atlas for the supported pattern types while keeping pattern selection a per-object layer property. The packed data uses a backend-safe texture form so the same pattern rules work in WebGL and WebGPU.
The package includes capabilities for these broad needs:
| Capability group | Visualization need |
|---|---|
| Brushing and data filtering | Show data near the pointer or within numeric and category rules |
| Path and fill styling | Add dashed, offset, or patterned visual treatment |
| Masking and clipping | Limit visible objects to a mask or clip region |
| Collision handling | Hide overlapping objects and control which objects take priority |
| Terrain and precision | Place objects on terrain or use higher coordinate precision |
Compatibility is part of the contract. An extension can ignore a layer that does not support its geometry or required data. Masking, collision filtering, and terrain also coordinate shared effects with the deck instance. They use flat common-space bounds for their render regions. Globe views use separate spherical-coordinate handling where required.
Clipping limits either whole instances or their rendered geometry to rectangular bounds. The extension chooses the mode from the layer shape unless the application sets it. Instance clipping follows the layer's source position transform, while geometry clipping uses a continuous flat projection and handles wrapped world copies around the bounds center. The WebGPU path receives the same mode and bounds contract as the other rendering path.
Masking uses one or more visible layers as named mask sources. A mask effect renders those sources into shared channels, then compatible layers use a channel by maskId to show or hide their instances or geometry. The effect supports up to four mask channels and does not support globe views. On WebGPU, the mask pass clears only the selected channel before it draws, so updating one mask does not erase the other active channels.
Terrain coordinates terrain and draped layers through shared height-map or cover textures. A terrain pass can write elevation, while other layers can read that elevation or use the terrain cover as their visual surface. TerrainExtension fits either layer anchors or layer geometry to that surface. Its automatic mode uses anchor-based offset fitting for anchored or extruded layers and geometry-based drape fitting for other layers. WebGPU supports the anchor-based offset mode and rejects drape mode.
The projection helpers provide one flat common-space contract for these spatial effects. They convert layer bounds and viewport bounds consistently across source coordinate systems, handle antimeridian bounds, and avoid intersecting flat layer bounds directly with spherical globe bounds. Globe views use separate spherical-coordinate handling where required. This includes conversion of meter offsets through the globe tangent plane before shared effects use flat common space.
See Layer extensions for the extension lifecycle and the capability-specific behavior.
References: modules/…/layer-extension.ts• L11-80 modules/…/brushing-extension.ts• L11-95 modules/…/shader-module.ts• L97-170 modules/…/data-filter-extension.ts• L25-35 modules/…/data-filter-extension.ts• L134-157 modules/…/data-filter-extension.ts• L160-184 modules/…/data-filter-extension.ts• L187-212 modules/…/data-filter-extension.ts• L244-339 modules/…/shader-plugin.ts• L42-105 modules/…/collision-filter-effect.ts• L26-107 modules/…/collision-filter-effect.ts• L127-175 modules/…/shader-module.ts• L147-189 modules/…/path-style-extension.ts• L33-57 modules/…/path-style-extension.ts• L219-237 modules/…/path-style-extension.ts• L311-373 modules/…/path-style-extension.ts• L397-427 modules/…/shaders.wgsl.ts• L34-168 modules/…/fill-style-extension.ts• L118-145 modules/…/fill-style-extension.ts• L226-245 modules/…/procedural-pattern.ts• L37-53 modules/…/shader-module.wgsl.ts• L7-25 modules/…/float-parameter-texture.ts• L7-25 modules/…/clip-extension.ts• L34-85 modules/…/shader-module.ts• L67-129 modules/…/clip-extension.ts• L83-117 modules/…/mask-effect.ts• L78-210 modules/…/mask-pass.ts• L30-118 modules/…/shader-module.ts• L9-16 modules/…/masked-color-clear.ts• L21-54 modules/…/terrain-extension.ts• L15-20 modules/…/terrain-extension.ts• L30-76 modules/…/shader-module.ts• L36-49 modules/…/shader-module.ts• L101-145 modules/…/projection-utils.ts• L39-79
Combined data path
The optional subsystems meet at the core layer boundary. JSON can describe the layer and its props, CARTO can supply the data and layer class, and extensions can add behavior before the core runtime renders the final layer.
Runtime relationship
An application can use these paths separately or together. For example, a JSON catalog can register a CARTO layer class and an extension class, while a CARTO map fetch can create layers that use the same extension capabilities directly.
flowchart TB
J[Declarative JSON] --> N[Runtime props and objects]
C[CARTO sources or map] --> L[CARTO layer instances]
N --> L
L --> X[Optional layer extensions]
X --> R[Core layer lifecycle]
R --> V[GPU visualization and interaction]
This relationship keeps data access, configuration, and layer behavior distinct. The core runtime receives ordinary layer objects at the end of the path, regardless of which optional subsystem created or enhanced them.
References: modules/…/index.ts• L7-17 modules/…/fetch-map.ts• L25-71 modules/…/layer-props.ts• L201-207 modules/…/layer.ts• L1005-1016
Change checklist
When these files or sections are changed, remember to consider these:
- Keep serialized
@@typeand@@functionnames aligned with the catalogs registered by JSON consumers. A name mismatch changes a usable object into a warning and a null result. - Keep CARTO descriptor types aligned with
LayerFactoryand with the source and tile data shapes expected by the matching layer classes. - Keep vector tile format detection aligned with coordinate-system handling, geometry and property tile merging, sublayer clipping, and automatic-label creation.
- Keep H3 and quadbin tile schemes aligned across cell-to-tile conversion, polygon bounds, cluster aggregation, heatmap density scaling, tile resolution, and source metadata.
- Keep heatmap color-range data, Deck color conventions, cell-resolution normalization, maximum-density reporting, and zoom-level transitions aligned. A change to palette packing or density scaling can alter both the visual result and any consumer of
onMaxDensityChange. - Keep extension default props, extension options, and the layer types that consume them aligned. A capability can appear valid at the prop level but have no effect on an incompatible layer.
- Keep GLSL and WGSL shader inputs, uniforms, visibility hooks, coordinate rules, and picking behavior aligned for every extension. A backend can otherwise render a different result while the layer API remains unchanged.
- Keep brushing attributes aligned with the target mode used by the shader. Pointer redraws must remain connected to the active deck event source.
- Keep data-filter attribute sizes, category maps, filter bit masks, and optional item-count aggregation aligned. Changes to one category channel can silently change which objects pass.
- Keep filtered-item count buffers, readback formats, and stale-result checks aligned across WebGL and WebGPU. A change can report the wrong count or report an old count after a new filter update.
- Keep collision groups, collision-map lifetime, viewport updates, and picking behavior aligned. A group change can silently make layers share the wrong overlap map or skip collision updates.
- Keep clip bounds in the same source and common spaces used by instance and geometry clipping. Changes to coordinate transforms must cover tile-local geometry, antimeridian wrapping, and WebGPU mode selection.
- Keep mask channel allocation, per-channel clearing, mask layer ids, coordinate conversion, and cached render bounds aligned. Globe views must continue to avoid flat-bound intersection.
- Keep terrain mode values aligned between terrain effects, texture bindings, flat bounds, globe position conversion, and renderer support. WebGPU must continue to select or enforce the supported
offsetmode while height-map and cover passes keep their distinct render roles. - Keep fill pattern names aligned with the atlas mapping or procedural pattern mapping. Keep the atlas or generated pattern data available to the layer that uses the fill capability.
- Keep procedural pattern definitions aligned with the shader's supported pattern types and value limits. Invalid definitions fail while the pattern data is prepared.
- Keep the procedural pattern texture format and WGSL bit-cast path aligned with the packed float records. A texture-type change can make valid pattern parameters unreadable on one backend.
- Keep path dash unit values aligned between the public option mapping and the shader branches. Changes to path-mode metrics must also preserve the data contract for CPU-readable geometry or supplied dash offsets.
- Keep path dash and offset coordinate stages ordered consistently across GLSL and WGSL. Both features change the same path coordinates and must not depend on extension merge order.
- Keep
Fp64Extensioncoordinate checks aligned with theproject64module. It is a deprecated path for supported longitude and latitude coordinate systems, not a general precision mode. - Keep flat common-space projection rules aligned between CPU bounds helpers, GPU projection behavior, source coordinate transforms, and mask, terrain, or clipping render regions. Globe viewport bounds are spherical and must not be intersected directly with flat layer bounds.
- Keep CARTO access-token handling aligned across map requests, tile requests, and any new source or loader path.
- Keep basemap output shapes compatible with the host map integration that consumes the returned basemap props.
- Keep the package's import and CommonJS entry points aligned with the bundled synchronous decoder path. A loader subpath that works only for one module system can break CARTO tile access for that host.
- Keep packed tile array types and compression flags aligned between CARTO tile schemas and the typed-array decoder. A mismatch can turn valid raster or spatial data into unusable layer input.
- Keep point-label defaults, collision extensions, and automatic-label sublayer props aligned. A label change can affect both visible text and the space reserved for collision checks.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| JSON names a class or function that is not in its configuration catalog | Conversion logs a warning and returns null for that value | Register every type and function used by the document |
| A JSON expression contains a function call | Conversion throws instead of producing an accessor | Use data-only property and value expressions |
| CARTO returns a descriptor type with no layer mapping | fetchMap throws because no deck.gl layer class is available | Add the mapping and its matching layer support before using the descriptor |
| A CARTO request lacks a valid access token | Data or tiles cannot be fetched from the protected source | Pass the token through the source or tile configuration |
| A quadbin cell is converted with the wrong tile scale or vertical origin | Cluster or heatmap geometry is placed in the wrong geographic area | Keep quadbin tile coordinates, the 512-unit tile space, coverage, and world-to-geographic conversion aligned |
| A native vector tile has invalid geometry or property tile URLs | The tile cannot produce the expected combined layer data | Preserve valid geometry and property tile templates together |
| A tile scheme changes without updating cluster or heatmap handling | H3 or quadbin cells use the wrong position, resolution, or density rules | Keep source metadata and the selected tile layer in step |
| Heatmap palette packing or density normalization changes without matching Deck color conventions and color scaling | The same data can use the wrong colors or appear too bright, too dim, or inconsistent between tile levels | Keep palette encoding, cell resolution, maximum-density reporting, and the heatmap color domain in the same contract |
| A fill pattern name has no atlas or procedural mapping | The pattern has no usable frame or pattern record and does not render as intended | Define every value returned by getFillPattern in the selected mapping |
| A procedural pattern has an unsupported type or invalid size, gap, angle, or skew | Pattern texture creation throws and the layer cannot use the procedural pattern | Use one of the supported pattern shapes and valid finite values |
| A procedural pattern texture is read with the wrong backend format | Pattern parameters become corrupted or the pattern becomes blank on one rendering backend | Keep the packed record format, texture format, and shader load path aligned |
Path-mode dashes use GPU-only getPath data without precomputed dash offsets | Dash metrics cannot be calculated and path styling throws | Provide readable path data or data.attributes.instanceDashOffsets |
| A dash unit is mapped differently in the shader and public option | Dash lengths change between modes or rendering backends | Keep DashUnits and both shader branches in the same order |
| Clip bounds use a coordinate space that does not match the layer source or rendered geometry | Instances or geometry are clipped in the wrong place | Apply the layer source transform for instance mode and the flat common projection for geometry mode |
| A globe viewport's spherical bounds are intersected directly with flat layer bounds | Mask or terrain render regions can be wrong or omit visible data | Convert layer bounds to flat common space and use globe-specific bounds handling |
| A mask layer id is empty or does not match a valid mask layer | Masking is disabled and a warning can be logged | Create the mask layer first and use the same id |
| More than four mask sources are active | Additional mask sources are not assigned a mask channel | Limit the active mask sources to four |
| A WebGPU mask clear resets the full color attachment instead of only the selected channel | Updating one mask can erase other active mask channels | Clear the selected channel with a masked draw inside the mask render pass |
Fp64Extension is used with an unsupported coordinate system | Shader setup throws instead of enabling legacy 64-bit projection | Use the extension only with its supported longitude and latitude coordinate systems |
| An extension is used on an unsupported layer type | The layer renders without that extension's capability | Check the extension's supported geometry and layer contract |
WebGPU selects terrain drape mode | Terrain setup throws because WebGPU supports anchor-based offset fitting only | Set terrainDrawMode: "offset" or let the extension infer the supported mode |
| A collision group changes without a collision-map refresh | Overlapping objects can remain visible or valid objects can stay hidden | Refresh the group map after viewport, bounds, loading, transition, or layer changes |
| A filtered-item count readback completes after a newer filter or data update | The callback can expose an old count | Discard readback results whose layer state or count version is no longer current |
| A CommonJS host cannot resolve the synchronous compression decoder | CARTO package loading or packed tile decoding fails before rendering | Keep the CommonJS bundle alias and package export in step with the decoder entry point |
| A packed tile declares a type or compression mode that the decoder does not support | Raster or spatial values fail to decode or have the wrong typed representation | Use the schema's supported type and compression contract |
| A point-label size or offset change is not reflected in collision padding | Labels can overlap or collision checks can hide the wrong labels | Update the visible and collision label paths together |
Key files
| File | Why to read it |
|---|---|
| modules/…/json-converter.ts | Shows how declarative JSON becomes runtime values and props |
| modules/…/json-configuration.ts | Defines the catalogs and hooks that connect JSON names to runtime objects |
| modules/…/fetch-map.ts | Shows how CARTO map descriptors become deck.gl layers |
| modules/…/index.ts | Defines the public CARTO layer, source, styling, and map-loading surface |
| modules/…/quadbin-utils.ts | Defines the quadbin tile-to-world coordinate boundary used by CARTO spatial layers |
| modules/…/vector-tile-layer.ts | Shows the CARTO vector tile path, format split, sublayer clipping, and automatic labels |
| modules/…/cluster-tile-layer.ts | Shows how H3 and quadbin tiles become viewport-aware cluster layers |
| modules/…/heatmap-tile-layer.ts | Shows how tiled cell weights become a density visualization |
| modules/…/package.json | Defines the CARTO package entry points and host-package contract |
| modules/…/build-cjs.mjs | Shows how the CommonJS package path keeps synchronous tile decoding available |
| modules/…/carto-vector-tile-loader.ts | Defines the packed vector tile decoding boundary |
| modules/…/index.ts | Lists the reusable layer capabilities exposed by the extensions package |
| modules/…/brushing-extension.ts | Illustrates pointer-driven visibility for compatible layers |
| modules/…/data-filter-extension.ts | Illustrates numeric and category filtering with optional visible-item counts |
| modules/…/shader-plugin.ts | Shows how filtering inputs and backend shader hooks form one layer capability |
| modules/…/collision-filter-effect.ts | Shows how shared collision maps control overlap across compatible layers |
| modules/…/fp64-extension.ts | Shows the deprecated precision extension and its coordinate-system boundary |
| modules/…/path-style-extension.ts | Illustrates dashed and offset styling for compatible path-like layers |
| modules/…/shaders.wgsl.ts | Shows the WebGPU path-style contract for dashes and offsets |
| modules/…/fill-style-extension.ts | Illustrates atlas-based and procedural pattern styling for compatible fill layers |
| modules/…/procedural-pattern.ts | Defines the supported procedural fill pattern shapes and validation boundary |
| modules/…/shader-module.wgsl.ts | Shows the WebGPU pattern rendering path |
| modules/…/float-parameter-texture.ts | Defines the cross-backend texture boundary for packed pattern parameters |
| modules/…/clip-extension.ts | Illustrates rectangular clipping for instances and geometry across coordinate spaces |
| modules/…/shader-module.ts | Defines the shared GLSL and WGSL clipping behavior and world-wrap handling |
| modules/…/mask-extension.ts | Illustrates how a layer selects and applies a named mask |
| modules/…/mask-pass.ts | Shows how mask channels are rendered and cleared across GPU backends |
| modules/…/masked-color-clear.ts | Defines the WebGPU draw used to clear one mask channel without changing the others |
| modules/…/terrain-effect.ts | Shows how terrain height maps and cover textures affect layer rendering |
| modules/…/terrain-extension.ts | Defines terrain fitting modes and the WebGPU mode boundary |
| modules/…/projection-utils.ts | Defines the common-space bounds used by mask, terrain, and clipping effects across source coordinate systems and flat or globe views |
| modules/…/layer-extension.ts | Defines the lifecycle boundary shared by all layer extensions |
| modules/…/clip-extension.ts | Defines the WebGPU clipping contract shared with the extension |
| modules/…/point-label-layer.ts | Shows how CARTO point labels combine visible text with collision-aware label space |
| modules/…/fast-pbf.ts | Shows the shared typed-array and gzip decode boundary for packed CARTO tile data |