Skip to content

Commit 9413d40

Browse files
martinRenoumfisher87
authored andcommitted
Identify panel: try to infer the feature name instead of showing the (geojupyter#906)
default name
1 parent b6b6275 commit 9413d40

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/base/src/panelview/components/identify-panel/IdentifyPanel.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ export const IdentifyPanelComponent: React.FC<IIdentifyComponentProps> = ({
8787
}));
8888
};
8989

90+
const getFeatureNameOrId = (feature: any, featureIndex: number) => {
91+
for (const key of Object.keys(feature)) {
92+
const lowerCase = key.toLowerCase();
93+
94+
if ((lowerCase.includes('name') || lowerCase === 'id') && feature[key]) {
95+
return feature[key];
96+
}
97+
}
98+
99+
return `Feature ${featureIndex + 1}`;
100+
};
101+
90102
return (
91103
<div
92104
className="jgis-identify-wrapper"
@@ -106,7 +118,7 @@ export const IdentifyPanelComponent: React.FC<IIdentifyComponentProps> = ({
106118
className={`jp-gis-layerGroupCollapser${visibleFeatures[featureIndex] ? ' jp-mod-expanded' : ''}`}
107119
tag={'span'}
108120
/>
109-
<span>Feature {featureIndex + 1}</span>
121+
<span>{getFeatureNameOrId(feature, featureIndex)}</span>
110122
</span>
111123

112124
{(() => {

0 commit comments

Comments
 (0)