Skip to content

Commit

Permalink
feat: update coordinate button to use the new result value
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The input of the render function is no longer grouped by featureType
 but returns an object for each feature that contains the feature, the layer and the feature type.

If you need the grouping, you can do the following

```
import { groupBy, mapValues } from 'lodash';

<CoordinateInfo
  resultRenderer={({ features }) => {
    const grouped = groupBy(features, 'featureType');
    const groupedAndMapped = mapValues(grouped, results => results.map(r => r.feature));
    // ...
  }}
/>
```
  • Loading branch information
simonseyock committed Jun 6, 2024
1 parent d0c5b3f commit a41b996
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@fortawesome/react-fontawesome": "^0.2.2",
"@terrestris/base-util": "^2.0.0",
"@terrestris/ol-util": ">=18",
"@terrestris/react-util": "^7.0.0",
"@terrestris/react-util": "^8.0.0",
"@types/lodash": "^4.17.4",
"ag-grid-community": "^31.3.2",
"ag-grid-react": "^31.3.2",
Expand Down
12 changes: 7 additions & 5 deletions src/CoordinateInfo/CoordinateInfo.example.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const CoordinateInfoExample = () => {
};

return (
Object.keys(features).length === 1 && features[Object.keys(features)[0]].length === 1 ?
features.length > 0 ?
<div>
<div
style={{
Expand Down Expand Up @@ -155,8 +155,8 @@ const CoordinateInfoExample = () => {
>
<Statistic
title="State"
value={getValue(features[Object.keys(features)[0]][0], 'STATE_NAME')
|| getValue(features[Object.keys(features)[0]][0], 'name')}
value={getValue(features[0].feature, 'STATE_NAME')
|| getValue(features[0].feature, 'name')}
/>
</Spin>
<Tooltip
Expand All @@ -166,7 +166,7 @@ const CoordinateInfoExample = () => {
style={{ marginTop: 16 }}
type="primary"
onClick={() => {
copy(features[Object.keys(features)[0]][0].get('STATE_NAME'));
copy(features[0].feature.get('STATE_NAME'));
}}
icon={
<FontAwesomeIcon
Expand All @@ -177,7 +177,9 @@ const CoordinateInfoExample = () => {
</Tooltip>
</div>
</div> :
<span>Click on a state to get details about the clicked coordinate.</span>
<span>
Click on a state to get details about the clicked coordinate.
</span>
);
}}
/>
Expand Down

0 comments on commit a41b996

Please sign in to comment.