@@ -62,7 +62,7 @@ function getGeojsonWriter() {
6262export abstract class BaseVectorTileLayer < T extends com . carto . layers . VectorTileLayer , U extends VectorTileLayerOptions > extends TileLayer < T , U > {
6363 listenerProjection ?: Projection ;
6464 listener ?: IVectorTileEventListener ;
65- nListener ?: com . akylas . carto . additions . AKVectorTileEventListener ;
65+ nListener ?: com . akylas . carto . additions . AKVectorTileEventListener | com . carto . layers . VectorTileEventListener ;
6666
6767 @nativeProperty layerBlendingSpeed : number ;
6868 @nativeProperty labelBlendingSpeed : number ;
@@ -79,16 +79,20 @@ export abstract class BaseVectorTileLayer<T extends com.carto.layers.VectorTileL
7979 }
8080 }
8181 }
82- setVectorTileEventListener ( listener : IVectorTileEventListener , projection ?: Projection ) {
82+ setVectorTileEventListener ( listener : IVectorTileEventListener | any , projection ?: Projection , nativeClass = com . akylas . carto . additions . AKVectorTileEventListener ) {
8383 this . listener = listener ;
8484 this . listenerProjection = projection ;
8585 if ( listener ) {
86- if ( ! this . nListener ) {
87- this . nListener = new com . akylas . carto . additions . AKVectorTileEventListener (
88- new com . akylas . carto . additions . AKVectorTileEventListener . Listener ( {
89- onVectorTileClicked : this . onTileClicked . bind ( this )
90- } )
91- ) ;
86+ if ( listener instanceof com . carto . layers . VectorTileEventListener ) {
87+ this . nListener = listener ;
88+ } else {
89+ if ( ! this . nListener ) {
90+ this . nListener = new nativeClass (
91+ new com . akylas . carto . additions . AKVectorTileEventListener . Listener ( {
92+ onVectorTileClicked : this . onTileClicked . bind ( this )
93+ } )
94+ ) ;
95+ }
9296 }
9397 this . getNative ( ) . setVectorTileEventListener ( this . nListener ) ;
9498 } else {
@@ -194,12 +198,12 @@ export abstract class BaseVectorLayer<T extends com.carto.layers.VectorLayer, U
194198 }
195199 }
196200 }
197- setVectorElementEventListener ( listener : IVectorElementEventListener , projection ?: Projection ) {
201+ setVectorElementEventListener ( listener : IVectorElementEventListener , projection ?: Projection , nativeClass = com . akylas . carto . additions . AKVectorElementEventListener ) {
198202 this . elementListener = listener ;
199203 this . projection = projection ;
200204 if ( listener ) {
201205 if ( ! this . nElementListener ) {
202- this . nElementListener = new com . akylas . carto . additions . AKVectorElementEventListener (
206+ this . nElementListener = new nativeClass (
203207 new com . akylas . carto . additions . AKVectorElementEventListener . Listener ( {
204208 onVectorElementClicked : this . onElementClicked . bind ( this )
205209 } )
@@ -285,12 +289,12 @@ export class EditableVectorLayer extends BaseVectorLayer<com.carto.layers.Editab
285289 this . native . setSelectedVectorElement ( element instanceof BaseNative ? element . getNative ( ) : element ) ;
286290 }
287291 }
288- setVectorEditEventListener ( listener : IVectorEditEventListener , projection ?: Projection ) {
292+ setVectorEditEventListener ( listener : IVectorEditEventListener , projection ?: Projection , nativeClass = com . akylas . carto . additions . AKVectorEditEventListener ) {
289293 this . editListener = listener ;
290294 this . projection = projection ;
291295 if ( listener ) {
292296 if ( ! this . nEditListener ) {
293- this . nEditListener = new com . akylas . carto . additions . AKVectorEditEventListener (
297+ this . nEditListener = new nativeClass (
294298 new com . akylas . carto . additions . AKVectorEditEventListener . Listener ( {
295299 onDragEnd : this . onDragEnd . bind ( this ) ,
296300 onDragMove : this . onDragMove . bind ( this ) ,
@@ -397,8 +401,7 @@ export class ClusteredVectorLayer extends BaseVectorLayer<com.carto.layers.Clust
397401 @nativeProperty maximumClusterZoom : number ;
398402 @nativeProperty ( {
399403 nativeGetterName : 'isAnimatedClusters'
400- } )
401- animatedClusters : boolean ;
404+ } ) animatedClusters : boolean ;
402405
403406 expandCluster ( element : VectorElement < any , any > , px : number ) {
404407 this . getNative ( ) . expandCluster ( element . getNative ( ) , px ) ;
0 commit comments