-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
✅ Deploy Preview for wfp-hungermap ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this 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.
There was a problem hiding this 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!
const ipcDataPromise = globalRepo.getIpcData(); | ||
const [countryMapData, disputedAreas, ipcData] = await Promise.all([ | ||
countryMapDataPromise, | ||
disputedAreasPromise, | ||
ipcDataPromise, | ||
]); | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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} />} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
if (hoveredPolygonId && (!feature || hoveredPolygonId !== feature.id)) { | ||
baseMap.setFeatureState({ source: 'countries', id: hoveredPolygonId }, { hover: false }); | ||
hoveredPolygonId = undefined; | ||
baseMap.getCanvas().style.cursor = ''; | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what issue exactly?
src/operations/map/MapOperations.ts
Outdated
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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. :)
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. |
The IPC Map with popOver on hovered colored countries