Create the layer. No network happens until it is added to a map; the models load in onAdd.
See MultiModelInstancesLayerOptions. id, a non-empty models and a
non-empty instances are required.
ReadonlyidA unique layer id.
ReadonlyrenderingEither "2d" or "3d". Defaults to "2d".
ReadonlytypeThe layer's type. Must be "custom".
Revert to the default (no-sun) lighting — the clearSun half of SunLightable (used when the
geo-sun system is disabled).
The anchor [lng, lat] (instances' centroid).
[lng, lat] in degrees, or null until loaded.
MapLibre CustomLayerInterface hook — invoked when the layer is added with map.addLayer;
initializes GL resources and uploads the instances.
MapLibre CustomLayerInterface hook — invoked when the layer is removed with map.removeLayer;
releases GL resources.
Resolve a canvas point to the 3D geographic position of the frontmost rendered instance surface — the screen→scene primitive behind measurement and slice placement.
Canvas X in CSS pixels, top-left origin (e.g. a MapLibre click event's e.point.x).
Canvas Y in CSS pixels, top-left origin.
Snap radius in CSS pixels (default 0 = exact pixel): the nearest mesh hit within the radius wins, so a click slightly off an edge still lands on the mesh.
The picked position (lng/lat degrees, height metres above the rendered ground datum,
plus the cross-layer-comparable depth01), or null on a miss / before the first frame.
Optional method called during a render frame to allow a layer to prepare resources or render into a texture.
The layer cannot make any assumptions about the current GL state and must bind a framebuffer before rendering.
Called during a render frame allowing the layer to draw into the GL context.
The layer can assume blending and depth state is set to allow the layer to properly blend and clip other layers. The layer cannot make any other assumptions about the current GL state.
If the layer needs to render to a texture, it should implement the prerender method
to do this and only use the render method for drawing directly into the main framebuffer.
The blend function is set to gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA). This expects
colors to be provided in premultiplied alpha form where the r, g and b values are already
multiplied by the a value. If you are unable to provide colors in premultiplied form you
may want to change the blend function to
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA).
Fade the models over the basemap.
Opacity in [0, 1] (clamped); 0 = transparent, 1 = opaque.
Show/hide the layer without removing it.
true to show, false to hide.
Draws SEVERAL distinct models across one point set. An "instance" here is a MultiModelInstance — a
[lng, lat, height]position, an optional scale and heading, and amodelIndexnaming which entry of the suppliedmodelslibrary to draw — so the caller provides the library (glTF/GLB URLs, raw GLB bytes, or pre-builtNormalizedMeshobjects) plus the instances. The layer resolves each model to a template, partitions the instances bymodelIndex, and issues one instanced draw per model. Add it withmap.addLayer; it needs a WebGL2 context (on WebGL1 it draws nothing rather than throwing) and Mercator — a non-affine (globe) frame hides it. Unlike ModelInstancesLayer there is nodatumoption and no terrain sampling: each instance's height is placed exactly as given.Example
See
MultiModelInstancesLayerOptions for every constructor option.