Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions packages/base/src/mainview/mainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2104,30 +2104,48 @@ export class MainView extends React.Component<IProps, IStates> {
case 'VectorTileLayer': {
const geometries: Geometry[] = [];
const features: any[] = [];
let foundAny = false;

this._Map.forEachFeatureAtPixel(e.pixel, (feature: FeatureLike) => {
foundAny = true;

let geom: Geometry | undefined;
let props = {};

if (feature instanceof RenderFeature) {
geom = toGeometry(feature);
} else if ('getGeometry' in feature) {
geom = feature.getGeometry();
}

const props = feature.getProperties();
const rawProps = feature.getProperties();
const fid = feature.getId?.() ?? rawProps?.fid;

if (rawProps && Object.keys(rawProps).length > 1) {
const { geometry, ...clean } = rawProps;
props = clean;
if (fid !== null) {
// TODO Clean the cache under some condition?
this._featurePropertyCache.set(fid, props);
}
} else if (fid !== null && this._featurePropertyCache.has(fid)) {
props = this._featurePropertyCache.get(fid);
}

if (geom) {
geometries.push(geom);
}
features.push({
...props,
});
if (props && Object.keys(props).length > 0) {
features.push(props);
}

return true;
});

if (features.length > 0) {
this._model.syncIdentifiedFeatures(features, this._mainViewModel.id);
} else if (!foundAny) {
this._model.syncIdentifiedFeatures([], this._mainViewModel.id);
}

if (geometries.length > 0) {
Expand Down Expand Up @@ -2335,4 +2353,5 @@ export class MainView extends React.Component<IProps, IStates> {
private _state?: IStateDB;
private _formSchemaRegistry?: IJGISFormSchemaRegistry;
private _annotationModel?: IAnnotationModel;
private _featurePropertyCache: Map<string | number, any> = new Map();
}
Loading