Skip to content

Commit

Permalink
Add Identify showLayerSelector config prop
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Feb 12, 2025
1 parent 4581d0b commit 7fdcd9b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
30 changes: 17 additions & 13 deletions components/IdentifyViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class IdentifyViewer extends React.Component {
removeLayer: PropTypes.func,
replaceImageUrls: PropTypes.bool,
setActiveLayerInfo: PropTypes.func,
showLayerSelector: PropTypes.bool,
showLayerTitles: PropTypes.bool,
theme: PropTypes.object,
zoomToExtent: PropTypes.func
Expand All @@ -185,6 +186,7 @@ class IdentifyViewer extends React.Component {
attributeCalculator: (/* layer, feature */) => { return []; },
attributeTransform: (name, value /* , layer, feature */) => value,
showLayerTitles: true,
showLayerSelector: true,
highlightAllResults: true
};
state = {
Expand Down Expand Up @@ -530,19 +532,21 @@ class IdentifyViewer extends React.Component {
} else {
body = (
<div className="identify-flat-results-list">
<div className="identify-selectbox">
<select className="identify-layer-select" onChange={(e) => {const selectedLayer = e.target.value; this.setState({ selectedLayer });}}>
<option value=''>{LocaleUtils.tr("identify.layerall")}</option>
{Object.keys(this.state.resultTree).sort().map(
layer => (
<option key={layer} value={layer}>
{layer}
</option>
))}
</select>
<span className="identify-buttonbox-spacer" />
<span>{LocaleUtils.tr("identify.featurecount")}: {Object.values(this.state.selectedLayer !== '' ? this.state.resultTree[this.state.selectedLayer] : this.state.resultTree ).flat().length}</span>
</div>
{this.props.showLayerSelector ? (
<div className="identify-selectbox">
<select className="identify-layer-select" onChange={(e) => {const selectedLayer = e.target.value; this.setState({ selectedLayer });}}>
<option value=''>{LocaleUtils.tr("identify.layerall")}</option>
{Object.keys(this.state.resultTree).sort().map(
layer => (
<option key={layer} value={layer}>
{layer}
</option>
))}
</select>
<span className="identify-buttonbox-spacer" />
<span>{LocaleUtils.tr("identify.featurecount")}: {Object.values(this.state.selectedLayer !== '' ? this.state.resultTree[this.state.selectedLayer] : this.state.resultTree ).flat().length}</span>
</div>
) : null}
{Object.keys(this.state.selectedLayer !== '' ? { [this.state.selectedLayer]: this.state.resultTree[this.state.selectedLayer] } : this.state.resultTree).map(layer => {
const layerResults = this.state.resultTree[layer];
return layerResults.map(result => {
Expand Down
1 change: 1 addition & 0 deletions doc/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ for customized queries and templates for the result presentation.
| initialRadiusUnits | `string` | The initial radius units of the identify dialog in radius mode. One of 'm', 'ft', 'km', 'mi'. | `'m'` |
| params | `object` | Extra params to append to the GetFeatureInfo request (i.e. `FI_POINT_TOLERANCE`, `FI_LINE_TOLERANCE`, `feature_count`, ...). Additionally, `region_feature_count` and `radius_feature_count` are supported. | `undefined` |
| replaceImageUrls | `bool` | Whether to replace an attribute value containing an URL to an image with an inline image. | `true` |
| showLayerSelector | `bool` | Whether to show a layer selector to filter the identify results by layer. | `true` |

LayerCatalog<a name="layercatalog"></a>
----------------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions plugins/Identify.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Identify extends React.Component {
replaceImageUrls: PropTypes.bool,
selection: PropTypes.object,
setCurrentTask: PropTypes.func,
/** Whether to show a layer selector to filter the identify results by layer. */
showLayerSelector: PropTypes.bool,
theme: PropTypes.object
};
static defaultProps = {
Expand All @@ -109,7 +111,8 @@ class Identify extends React.Component {
side: 'left'
},
initialRadiusUnits: 'm',
highlightAllResults: true
highlightAllResults: true,
showLayerSelector: true
};
state = {
mode: 'Point',
Expand Down Expand Up @@ -375,7 +378,9 @@ class Identify extends React.Component {
iframeDialogsInitiallyDocked={this.props.iframeDialogsInitiallyDocked}
longAttributesDisplay={this.props.longAttributesDisplay}
replaceImageUrls={this.props.replaceImageUrls}
role="body" />
role="body"
showLayerSelector={this.props.showLayerSelector}
/>
);
}
resultWindow = (
Expand Down

0 comments on commit 7fdcd9b

Please sign in to comment.