Create the layer. No network happens until it is added to a map; the model loads in onAdd.
See ModelInstancesLayerOptions. id, model 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 model 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 ONE shared glTF/GLB model at many geographic points in a single instanced pass. An "instance" is a
[lng, lat, height]position plus an optional scale and heading (degrees CW from north), so the caller supplies exactly two things: the model — a URL, raw GLB bytes, or a pre-builtNormalizedMesh— and the instance list. The layer anchors at the instances' centroid and, on the default'basemap'datum, samples the terrain PER INSTANCE and re-seats as DEM tiles land, so a spread of models follows a slope. 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. Nothing is fetched until the layer is added to a map.Example
See