Skip to content

Commit d483ea9

Browse files
committed
chore: refactoring
1 parent 5b8ffd1 commit d483ea9

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/ui-carto/layers/vector.android.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { Layer, TileLayer } from '.';
22
import { BaseNative, nativeProperty } from '..';
33
import { fromNativeMapPos, fromNativeScreenPos } from '../core';
44
import { Projection } from '../projections';
5-
import { nativeVariantToJS } from '../utils';
65
import { VectorElement } from '../vectorelements';
7-
import { Line } from '../vectorelements/line';
86
import { MBVectorTileDecoder, VectorTileDecoder } from '../vectortiles';
97
import {
108
CartoOfflineVectorTileLayerOptions,
@@ -219,13 +217,9 @@ export abstract class BaseVectorLayer<T extends com.carto.layers.VectorLayer, U
219217
}
220218
onElementClicked(info: com.carto.ui.VectorElementClickInfo) {
221219
if (this.elementListener && this.elementListener.onVectorElementClicked) {
222-
let element: VectorElement<any, any>;
223220
const nElement = info.getVectorElement();
224-
if (nElement instanceof com.carto.vectorelements.Line) {
225-
element = new Line(undefined, nElement);
226-
} else {
227-
element = new VectorElement(undefined, nElement);
228-
}
221+
const element = new VectorElement(undefined, nElement);
222+
229223
let position = info.getClickPos();
230224
let elementPos = info.getElementClickPos();
231225
if (this.projection) {
@@ -239,6 +233,7 @@ export abstract class BaseVectorLayer<T extends com.carto.layers.VectorLayer, U
239233
clickType: info.getClickType(),
240234
layer: this,
241235
element,
236+
native: nElement,
242237
metaData: element.metaData,
243238
position: fromNativeMapPos(position),
244239
elementPos: fromNativeMapPos(elementPos)

src/ui-carto/layers/vector.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface VectorTileEventData<T = DefaultLatLonKeys> {
3636
export interface VectorElementEventData<T = DefaultLatLonKeys> {
3737
clickType: ClickType;
3838
layer: BaseVectorTileLayer<any, any>;
39+
native: any;
3940
// featureId: number;
4041
// featureData: { [k: string]: string };
4142
// featureLayerName: string;

src/ui-carto/layers/vector.ios.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export class NTVectorElementEventListenerImpl extends NTVectorElementEventListen
4545
public onVectorElementClicked(info: NTVectorElementClickInfo) {
4646
const owner = this._owner.get();
4747
if (owner && owner.onVectorElementClicked) {
48-
const element = new VectorElement(undefined, info.getVectorElement());
48+
const nElement = info.getVectorElement();
49+
const element = new VectorElement(undefined, nElement);
4950
let position = info.getClickPos();
5051
let elementPos = info.getElementClickPos();
5152
if (this.projection) {
@@ -59,6 +60,7 @@ export class NTVectorElementEventListenerImpl extends NTVectorElementEventListen
5960
clickType: info.getClickType() as any,
6061
layer: this._layer.get() as any,
6162
element,
63+
native: nElement,
6264
metaData: element.metaData,
6365
position: fromNativeMapPos(position),
6466
elementPos: fromNativeMapPos(elementPos)
@@ -300,7 +302,8 @@ export class ClusteredVectorLayer extends BaseVectorLayer<NTClusteredVectorLayer
300302
@nativeProperty maximumClusterZoom: number;
301303
@nativeProperty({
302304
nativeGetterName: 'isAnimatedClusters'
303-
}) animatedClusters: boolean;
305+
})
306+
animatedClusters: boolean;
304307

305308
expandCluster(element: VectorElement<any, any>, px: number) {
306309
this.getNative().expandClusterPx(element.getNative(), px);

0 commit comments

Comments
 (0)