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

Feature/f 51 ipc map #35

Merged
merged 17 commits into from
Nov 22, 2024
Merged

Feature/f 51 ipc map #35

merged 17 commits into from
Nov 22, 2024

Conversation

ahmedfarouk2000
Copy link
Collaborator

The IPC Map with popOver on hovered colored countries
image

  • I didn't use any layers in here since its only about coloring the IPCs countries.
  • generateColorMap func: the logic looks complicated but its becase the IPCs data from endpoint that ends with ipc.json does not include all the data needed thus I need to get them from countryMapData endpoint that ends with adm0data.json, so I think its better to refactor those endpoints.

Copy link

netlify bot commented Nov 17, 2024

Deploy Preview for wfp-hungermap ready!

Name Link
🔨 Latest commit b740a89
🔍 Latest deploy log https://app.netlify.com/sites/wfp-hungermap/deploys/67406eea11e29c0008e8604e
😎 Deploy Preview https://deploy-preview-35--wfp-hungermap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@jschoedl jschoedl left a comment

Choose a reason for hiding this comment

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

LGTM! Although I haven't worked with Mapbox yet and can't say too much about it.

I added some suggestions regarding types and variable names.

src/operations/IPC/IpcMapOperations.tsx Outdated Show resolved Hide resolved
src/operations/IPC/IpcMapOperations.tsx Outdated Show resolved Hide resolved
src/operations/IPC/IpcMapOperations.tsx Outdated Show resolved Hide resolved
src/operations/IPC/IpcMapOperations.tsx Outdated Show resolved Hide resolved
src/operations/map/MapOperations.ts Outdated Show resolved Hide resolved
src/operations/map/MapOperations.ts Outdated Show resolved Hide resolved
src/operations/map/MapOperations.ts Outdated Show resolved Hide resolved
src/operations/map/MapOperations.ts Show resolved Hide resolved
src/styles/globals.css Outdated Show resolved Hide resolved
tailwind.config.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@marinovl7 marinovl7 left a comment

Choose a reason for hiding this comment

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

Please revisit the data fetching issues with @Tschonti and communicate about the tooltip/popup with @ArmanpreetGhotra. Precise naming for the functions is needed to distinguish between ipc functions, nutrition functions etc. Overall the request and the functionality are perfect!

Comment on lines +14 to +20
const ipcDataPromise = globalRepo.getIpcData();
const [countryMapData, disputedAreas, ipcData] = await Promise.all([
countryMapDataPromise,
disputedAreasPromise,
ipcDataPromise,
]);

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Tschonti we should not fetch the IPC Data here right? Any suggestions where to move this, so that we fetch the data only on sidebar click on the ipc icon

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah it'd be great if we didn't fetch it here, but it was done so the mapbox layers and interactivity can be set up with this data. I'm not sure if mapbox is okay with dynamically creating a new layer (though it probably is).

the IPC data endpoint is ~21 KB, which is not that small, but way smaller than adm0 for example, so I don't think it makes a big difference to prefetch this.

@@ -24,7 +24,7 @@ export default function Map({ countries, disputedAreas }: MapProps) {
style={{ height: '100%', width: '100%', zIndex: 1 }}
>
<AlertContainer />
{countries && <VectorTileLayer countries={countries} disputedAreas={disputedAreas} />}
{countries && <VectorTileLayer countries={countries} disputedAreas={disputedAreas} ipcData={ipcData} />}
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe a new layer would be needed for the normal VectorTile layer instead? @Tschonti

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried not to have additional layer, since having additional layer will have some sort of unnatural behaviour when zooming in or out (not sure if it's solvable or not)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this will depend on IPC/CH Country View if this will show details about country ipc phases thus, its better to have a seprate layer.

src/operations/map/MapOperations.ts Outdated Show resolved Hide resolved
Comment on lines 120 to 124
if (hoveredPolygonId && (!feature || hoveredPolygonId !== feature.id)) {
baseMap.setFeatureState({ source: 'countries', id: hoveredPolygonId }, { hover: false });
hoveredPolygonId = undefined;
baseMap.getCanvas().style.cursor = '';
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

When you hover a country the country color is set to nothing, this needs to be fixed, maybe that is causing the issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what issue exactly?

Comment on lines 151 to 160
const formattedPopNum = ipc_popnmbr.toLocaleString('en-US', {
useGrouping: true,
});
const title = `${countryName}`;
const body = `Date of analysis: ${date_of_analysis} <br> Validity period: ${analysis_period}`;
const conclusion = `${formattedPopNum} people in IPC/CH Phase 3 and above <br> (${ipc_percent}% of people in the analyzed areas)`;

const popupContent = this.generatePopupContent(title, body, conclusion);
popup.setLngLat(e.lngLat).setHTML(popupContent).addTo(baseMap);
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we use our tooltip here? Maybe align with @ArmanpreetGhotra

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can for sure, but I prefer using the mapBox pop up which adaptively adjusts its position based on the mouse's location. e.g if there is no space on the right side of the screen, the popup will automatically appear on the left, and so on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

src/operations/map/MapOperations.ts Show resolved Hide resolved
Copy link
Collaborator

@jschoedl jschoedl left a comment

Choose a reason for hiding this comment

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

One small remark - the rest looks fine for me. :)

src/operations/map/MapOperations.ts Outdated Show resolved Hide resolved
@Tschonti
Copy link
Collaborator

I merged main - the MapOperations file changed a lot, so there was a huge merge conflict and had to refactor this solution to make it work. The only thing that's different than before the merge is that the inactive countries are still greyed out on the IPC map.

@marinovl7 marinovl7 merged commit 207eab5 into main Nov 22, 2024
5 checks passed
@marinovl7 marinovl7 deleted the feature/f-51-ipc-map branch November 22, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants