@@ -18,14 +18,19 @@ import Texture from '2gl/Texture';
1818import type Vao from '2gl/Vao' ;
1919import type ShaderProgram from '2gl/ShaderProgram' ;
2020
21- export type LayerProps < LayerT extends Layer > = Partial < LayerT [ 'props' ] > & {
21+ export type DeckInternalLayerProps = {
2222 id : string ;
2323 renderingMode ?: '2d' | '3d' ;
2424 deck : Deck ;
2525 type : any ;
2626 antialiasing ?: boolean ;
2727} ;
2828
29+ export type LayerProps < LayerT extends Layer > = Partial < LayerT [ 'props' ] > & DeckInternalLayerProps ;
30+
31+ /**
32+ * A class that provides rendering any deck.gl layer inside the MapGl canvas / WebGL context.
33+ */
2934export class Deck2gisLayer < LayerT extends Layer > implements DeckCustomLayer {
3035 id : string ;
3136 type : 'custom' ;
@@ -44,6 +49,22 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
4449 private vao ?: Vao ;
4550
4651 /* eslint-disable no-this-before-super */
52+ /**
53+ * Example:
54+ * ```js
55+ * const deckLayer = new mapgl.Deck2gisLayer(map, {
56+ * id: 'deckLayer',
57+ * deck,
58+ * type: HexagonLayer,
59+ * data,
60+ * getPosition: (d) => [d.point.lon, d.point.lat]
61+ * });
62+ *
63+ * map.addLayer(deckLayer);
64+ * ```
65+ * @param map The map instance.
66+ * @param options Deck2gisLayer initialization options.
67+ */
4768 constructor ( props : LayerProps < LayerT > ) {
4869 if ( ! props . id ) {
4970 throw new Error ( 'Layer must have a unique id' ) ;
@@ -58,6 +79,11 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
5879 this . antialiasing = Boolean ( props . antialiasing ) ;
5980 }
6081
82+ /**
83+ * @hidden
84+ * @internal
85+ * MapGL calls this method after adding a layer to a map.
86+ */
6187 public onAdd = ( ) => {
6288 if ( ! this . map && this . props . deck ) {
6389 const map = ( this . props . deck . props as CustomRenderProps ) . _2gisData . _2gisMap ;
@@ -94,12 +120,20 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
94120 }
95121 } ;
96122
123+ /**
124+ * @hidden
125+ * @internal
126+ * MapGL calls this method after removing a layer from a map.
127+ */
97128 public onRemove = ( ) => {
98129 if ( this . deck ) {
99130 removeLayer ( this . deck , this ) ;
100131 }
101132 } ;
102133
134+ /**
135+ * Sets layer properties and updates the layer.
136+ */
103137 public setProps ( props : Partial < LayerProps < LayerT > > ) {
104138 // id cannot be changed
105139 Object . assign ( this . props , props , { id : this . id } ) ;
@@ -110,6 +144,11 @@ export class Deck2gisLayer<LayerT extends Layer> implements DeckCustomLayer {
110144 }
111145 }
112146
147+ /**
148+ * @hidden
149+ * @internal
150+ * MapGL calls this method on each map frame rendering.
151+ */
113152 public render = ( ) => {
114153 if (
115154 ! this . deck ||
0 commit comments