@@ -74,6 +74,14 @@ export class NTVectorElementEventListenerImpl extends NTVectorElementEventListen
7474 }
7575}
7676
77+ let geojsonWriter: NTGeoJSONGeometryWriter;
78+ function getGeojsonWriter() {
79+ if (!geojsonWriter) {
80+ geojsonWriter = NTGeoJSONGeometryWriter.alloc().init();
81+ }
82+ return geojsonWriter;
83+ }
84+
7785@NativeClass
7886export class NTVectorTileEventListenerImpl extends NTVectorTileEventListener {
7987 private _layer: WeakRef<BaseVectorLayer<any, any>>;
@@ -104,23 +112,31 @@ export class NTVectorTileEventListenerImpl extends NTVectorTileEventListener {
104112 let position = info.getClickPos();
105113 let featurePos = geometry.getCenterPos();
106114
115+ let projection: NTProjection;
116+ const dataSourceProjection = this._layer.get().getNative().getDataSource().getProjection();
107117 if (this.projection) {
108- const layerProj = this._layer
109- .get()
110- .getNative()
111- .getDataSource()
112- .getProjection();
113- const nProj = this.projection.getNative();
114- featurePos = nProj.fromWgs84(layerProj.toWgs84(featurePos));
115- position = nProj.fromWgs84(layerProj.toWgs84(position));
118+ projection = this.projection.getNative();
119+ featurePos = projection.fromWgs84(dataSourceProjection.toWgs84(featurePos));
120+ position = projection.fromWgs84(dataSourceProjection.toWgs84(position));
116121 }
122+ const geoFeature = {
123+ id: info.getFeatureId(),
124+ layer: info.getFeatureLayerName(),
125+ get geometry() {
126+ const writer = getGeojsonWriter();
127+ writer.setSourceProjection(dataSourceProjection);
128+ return JSON.parse(getGeojsonWriter().writeGeometry(geometry));
129+ },
130+ properties: nativeVariantToJS(info.getFeature().getProperties()),
131+ };
117132 return (
118133 owner.onVectorTileClicked({
119134 clickType: info.getClickType() as any,
120135 layer: this._layer.get() as any,
121- featureId: info.getFeatureId(),
122- featureData: nativeVariantToJS(info.getFeature().getProperties()),
123- featureLayerName: info.getFeatureLayerName(),
136+ feature: geoFeature,
137+ featureId: geoFeature.id,
138+ featureData: geoFeature.properties,
139+ featureLayerName: geoFeature.layer,
124140 featureGeometry: geometry,
125141 featurePosition: fromNativeMapPos(featurePos),
126142 position: fromNativeMapPos(position)
@@ -195,7 +211,7 @@ export class VectorLayer extends BaseVectorLayer<NTVectorLayer, VectorLayerOptio
195211 if (!!options.dataSource) {
196212 const dataSource = options.dataSource.getNative();
197213 if (dataSource) {
198- return NTVectorLayer.alloc().initWithDataSource(( options.dataSource as VectorDataSource<any, any>) .getNative());
214+ return NTVectorLayer.alloc().initWithDataSource(options.dataSource.getNative());
199215 }
200216 }
201217 return null;
@@ -247,7 +263,7 @@ export class EditableVectorLayer extends BaseVectorLayer<NTEditableVectorLayer,
247263 if (!!options.dataSource) {
248264 const dataSource = options.dataSource.getNative();
249265 if (dataSource) {
250- const result = NTEditableVectorLayer.alloc().initWithDataSource(( options.dataSource as VectorDataSource<any, any>) .getNative());
266+ const result = NTEditableVectorLayer.alloc().initWithDataSource(options.dataSource.getNative());
251267 // result.setVectorEditEventListener(NTVectorEditEventListenerImpl.initWithOwner(new WeakRef(this)));
252268 // result.setVectorElementEventListener(NTVectorElementEventListenerImpl.initWithOwner(new WeakRef(this)));
253269 return result;
0 commit comments