The
LayerManager
class is an internal class that apps normally would not want to use. It was initially exposed primarily to enable deck.gl to be used without React, however as of deck.gl v5.0 you are more likely to want to use the newDeck
class (or theDeckGL
React Component). Those classes create aLayerManager
under the hood to handle layer management, and you do not need to use this class directly.
The LayerManager
class handles updates, drawing and picking for a set of layers.
For more information consult the Using Standalone article.
Creates a new LayerManager
instance.
new LayerManager(gl, {eventManager: ...}})`
Parameters:
Checks if layers need to be redrawn.
layerManager.needsRedraw({clearRedrawFlags = false});
Parameters:
clearRedrawFlags
(Bool) - Reset the needs redraw status
Returns:
true
if redraw is needed.
Returns an list of layers, optionally be filtered by a list of layer ids.
const layers = layerManager.getLayers({layerIds=[]});
Parameters:
layerIds
(String[], optional) - A list of layer id strings. If supplied, the returned list will only contain layers whoseid
property matches (see note) one of the strings in the list.
Returns:
Layer[]
- array of layer instances.
Notes:
- The returned list of layers is "expanded" in the sense that composite layers will have been recursively rendered and the list will thus only contain primitive layers.
- When supplying the layer id of a composite layer, all the sub layers rendered by that layer will be included.
- layer id matching checks that a layer id starts with one of the supplied strings. This ensures that sublayers rendered by a composite layer with the given id will also be included in the matched list.
Updates parameters.
layerManager.setParameters({
useDevicePixels,
pickingRadius,
onLayerClick,
onLayerHover
});
Parameters:
useDevicePixels
(Boolean
, optional) - Whether to use retina/HD display or not.eventManager
- A source of DOM input eventspickingRadius
(Number
, optional) - "Fuzziness" of picking (px), to support fat-fingering.onLayerClick
(Function
, optional) - A handler to be called when any layer is clicked.onLayerHover
(Function
, optional) - A handler to be called when any layer is hovered over.
Notes:
- The event "source" is expected to provide
on()
/off()
methods for registration, and to call registered handlers with an "Event" object of the following shape:offsetCenter
(Object: {x, y}) - center of the eventsrcEvent
(Object) - native JS Event object
Updates the current views.
layerManager.setViews(views);
Parameters:
views
(View[]
) - The new View instances.
Provide a new list of layers. Layers will be matched against old layers, and any composite layers will be recursively expanded into primitive layers.
layerManager.updateLayers({newLayers});
newLayers
(Layer[]) - Array of layers
Updates the current list of layers.
Draw all layers.
layerManager.drawLayers({pass});
Parameters:
pass
(String) - The render pass identifier, for debugging purpose
Pick the closest info at given coordinate.
layerManager.pickLayer({x, y, mode, radius = 0, layerIds})
Parameters:
x
(Number) - The x position of the pointery
(Number) - The y position of the pointermode
(String) - One ofhover
orclick
Get all unique infos within a bounding box.
layerManager.queryLayer({x, y, width, height, layerIds});
Parameters:
x
(Number) - The x position of the pointery
(Number) - The y position of the pointer