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

Allow <Map> component comparison to support configurable datasets/layers #1150

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion app/scripts/components/common/blocks/block-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ interface MapBlockProps {
datasets: VedaDatum<DatasetData>;
dateTime?: string;
compareDateTime?: string;
compareDatasetId?: string;
compareLayerId?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: compareDatasetId, no need to capitalize the s but do we need to pass that in? It wont be used it looks like. datasetId is never referenced from baseMapStaticCompareData

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is optional. We have to pass tha in ,if only we want to compare the datasets.

center?: [number, number];
zoom?: number;
compareLabel?: string;
Expand Down Expand Up @@ -146,6 +148,8 @@ function MapBlock(props: MapBlockProps) {
layerId,
dateTime,
compareDateTime,
compareDatasetId,
compareLayerId,
compareLabel,
center,
zoom,
Expand All @@ -166,7 +170,13 @@ function MapBlock(props: MapBlockProps) {
const layersToFetch = useMemo(() => {
const [baseMapStaticData] = reconcileDatasets([layerId], datasetLayers, []);
let totalLayers = [baseMapStaticData];
const baseMapStaticCompareData = baseMapStaticData.data.compare;
const baseMapStaticCompareData =
(!!compareDatasetId && !!compareLayerId)
? {
datasetId: compareDatasetId,
layerId: compareLayerId
}
: baseMapStaticData.data.compare;
if (baseMapStaticCompareData && 'layerId' in baseMapStaticCompareData) {
const compareLayerId = baseMapStaticCompareData.layerId;
const [compareMapStaticData] = reconcileDatasets(
Expand Down
2 changes: 2 additions & 0 deletions docs/content/MDX_BLOCKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ Syntax for Chart used in Wide Figure Block looks like this. Check how the data i
| datasetId | string | `''` | `id` defined in dataset mdx. |
| layerId | string | `''` | `id` for layer to display. The layer should be a part of the dataset above. |
| dateTime | string | `''` | Optional. This string should follow `yyyy-mm-dd` format. When omitted, the very first available dateTime for the dataset will be displayed |
| compareDatasetId | string | `''` | `id` The `id` defined in the dataset MDX. Include this only if a comparison with the dataset defined by `datasetId` is needed. |
| compareLayerId | string | `''` | `id` The `id` for the comparison layer to display. This layer must be part of the comparison dataset specified by `compareDatasetId` . |
| compareDateTime | string | `''` | Optional. This string should follow `yyyy-mm-dd` format. A date should only be specified if you wish to display the comparison slider |
| compareLabel | string | `''` | Text to display over the map when the comparison is active. If is for example used to indicate what dates are being compared. If not provided it will default to the value specified in the [dataset layer configuration](./frontmatter/layer.md#compare) |
| projectionId | string | `mercator` | The id of the [projection](./frontmatter/layer.md#projections) to load. |
Expand Down
Loading