Before creating a new layer, it is recommended that you verify that you can not achieve the desired effect either through layer subclassing or through using composite layers.
There are a couple of ways to build a layer in deck.gl, and it is helpful to consider what approach will serve you best before starting:
Your layer class must be a subclass of Layer.
import {Layer} from 'deck.gl';
class AwesomeLayer extends Layer {...}
It can be a direct subclass of Layer
, or extend another layer.
Store the layer name in the layerName
static property on your Layer
subclass:
AwesomeLayer.layerName = 'AwesomeLayer';
The layer name will be used as the default id of layer instances and also during debugging.
The list of properties is the main API your new layer will provide to applications. So it makes sense to carefully consider what properties your layer should offer.
You also need to define the default values of the layer's properties.
The most efficient method of doing this is to define a static defaultProps
member on your layer class.
AwesomeLayer.defaultProps = {
color: [255, 0, 0],
opacity: 0.5
};
Also consider the properties of the base Layer class, as well as any other inherited properties if you are deriving.