Skip to content

Commit 3ab8001

Browse files
committed
fix: events update
1 parent ec84932 commit 3ab8001

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

src/layers/vector.ios.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,25 @@ export class NTVectorTileEventListenerImpl extends NTVectorTileEventListener {
117117
const geoFeature = {
118118
id: info.getFeatureId(),
119119
layer: info.getFeatureLayerName(),
120+
_nativeGeometry: geometry,
120121
get geometry() {
121-
const writer = getGeojsonWriter();
122-
writer.setSourceProjection(dataSourceProjection);
123-
return JSON.parse(getGeojsonWriter().writeGeometry(geometry));
122+
if (!this._parsedGeometry) {
123+
const writer = getGeojsonWriter();
124+
writer.setSourceProjection(dataSourceProjection);
125+
this._geometry = getGeojsonWriter().writeGeometry(this._nativeGeometry);
126+
this._parsedGeometry = JSON.parse(this._geometry);
127+
}
128+
return this._parsedGeometry;
129+
},
130+
get _properties() {
131+
return info.getFeature().getProperties().toString();
132+
},
133+
get properties() {
134+
if (!this._parsedProperties) {
135+
this._parsedProperties = JSON.parse(this._properties);
136+
}
137+
return this._parsedProperties;
124138
},
125-
properties: nativeVariantToJS(info.getFeature().getProperties()),
126139
};
127140
return (
128141
owner.onVectorTileClicked({

src/ui/index.android.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class CartoMap<T = DefaultLatLonKeys> extends CartoViewBase {
122122

123123
getOptions() {
124124
if (this.mapReady) {
125-
return this.mapView.getOptions() as MapOptions;
125+
return this.mapView.getOptions() as any as MapOptions;
126126
}
127127
return null;
128128
}
@@ -151,19 +151,19 @@ export class CartoMap<T = DefaultLatLonKeys> extends CartoViewBase {
151151
if (this.hasListeners(MapClickedEvent)) {
152152
this.sendEvent(MapClickedEvent, {
153153
android: mapClickInfo,
154-
get clickInfo(){
154+
get clickInfo() {
155155
return {
156156
get duration() {
157-
return mapClickInfo.getClickInfo().getDuration()
158-
}
159-
}
157+
return mapClickInfo.getClickInfo().getDuration();
158+
},
159+
};
160160
},
161-
get clickType () {
162-
return mapClickInfo.getClickType().swigValue()
161+
get clickType() {
162+
return mapClickInfo.getClickType().swigValue();
163+
},
164+
get position() {
165+
return fromNativeMapPos(mapClickInfo.getClickPos());
163166
},
164-
get position () {
165-
return fromNativeMapPos(mapClickInfo.getClickPos())
166-
}
167167
});
168168
}
169169
},

0 commit comments

Comments
 (0)