Skip to content

Commit 0fcba0a

Browse files
committed
fix(ios): vector click event fix

1 parent 2485fae commit 0fcba0a

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface VectorTileEventData<T = DefaultLatLonKeys> {
2727
feature: any; // geojson object
2828
featureId: number;
2929
featureData: { [k: string]: string };
30+
featureGeometryPosIndex: number;
3031
featureLayerName: string;
3132
position: GenericMapPos<T>;
3233
featurePosition: GenericMapPos<T>;

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ export class NTVectorTileEventListenerImpl extends AKVectorTileEventListener {
9999
const geometry = feature.getGeometry();
100100
let position = info.getClickPos();
101101
const geoPosIndex = info.getFeaturePosIndex();
102-
let featurePos = geoPosIndex !== -1 && geometry instanceof com.carto.geometry.MultiPointGeometry ? geometry.getGeometry(geoPosIndex).getCenterPos() : geometry.getCenterPos();
102+
let featurePos: NTMapPos;
103+
if (geoPosIndex !== -1 && /MultiPoint/.test(geometry.constructor.name)) {
104+
featurePos = (geometry as NTMultiPointGeometry).getGeometry(geoPosIndex)?.getCenterPos();
105+
}
106+
if (!featurePos) {
107+
featurePos = geometry.getCenterPos();
108+
}
103109

104110
let projection: NTProjection;
105111
const dataSourceProjection = this._layer.get().getNative().getDataSource().getProjection();
@@ -141,6 +147,7 @@ export class NTVectorTileEventListenerImpl extends AKVectorTileEventListener {
141147
featureData: geoFeature.properties,
142148
featureLayerName: geoFeature.layer,
143149
featureGeometry: geometry,
150+
featureGeometryPosIndex: geoPosIndex,
144151
featurePosition: fromNativeMapPos(featurePos),
145152
position: fromNativeMapPos(position)
146153
}) || false

src/ui-carto/utils/index.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class ZippedAssetPackage extends BaseNative<NTZippedAssetPackage, ZippedA
8989
return NTZippedAssetPackage.alloc().initWithZipData(vectorTileStyleSetData);
9090
}
9191
} else {
92-
throw new Error(`could not find zip file: ${options.zipPath}(${zipPath})`)
92+
throw new Error(`could not find zip file: ${options.zipPath}(${zipPath})`);
9393
}
9494
} catch (error) {
9595
console.error(`ZippedAssetPackage(${zipPath}, ${options.zipPath}): ${error}`);

0 commit comments

Comments
 (0)