Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CoordinateInfo fetch options #3654

Merged
merged 1 commit into from
Nov 29, 2023
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
18 changes: 13 additions & 5 deletions src/CoordinateInfo/CoordinateInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ export interface CoordinateInfoProps {
map: OlMap;
/**
* Optional request options to apply (separated by each query layer, identified
* by its internal ol id).
* by its internal ol id or a callback function).
*/
fetchOpts: {
[uid: string]: RequestInit;
};
fetchOpts:
| {
[uid: string]: RequestInit;
}
| ((layer: WmsLayer) => RequestInit);
/**
* Callback function that gets called if all features are fetched successfully
* via GetFeatureInfo.
Expand Down Expand Up @@ -168,7 +170,13 @@ export class CoordinateInfo extends React.Component<CoordinateInfoProps, Coordin
}
);
if (featureInfoUrl) {
promises.push(fetch(featureInfoUrl, fetchOpts[getUid(l)]));
let opts;
if (fetchOpts instanceof Function) {
opts = fetchOpts(l as WmsLayer);
} else {
opts = fetchOpts[getUid(l)];
}
promises.push(fetch(featureInfoUrl, opts));
}

return !drillDown;
Expand Down
Loading