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

Issue #373 #376

Merged
merged 4 commits into from
Aug 24, 2023
Merged

Issue #373 #376

merged 4 commits into from
Aug 24, 2023

Conversation

minhnguyenxuan60
Copy link
Contributor

Summary

Add a new field (city) into Dataframe so that we can tell which city the current dataset is inside MapViz. Change index.tsx and socrataResultsToDataframe.ts files accordingly so that we can get the city abbreviation. Add a json file to store location of each city (for now, it only has Chicago and New York).

Screenshots or Videos (if applicable)

Example of what it looks like when click on map under visualize tab for a dataset in Chicago.

image

Example of what it looks like whne click on map under visualize tab for a dataset in New York.

image

Related Issues

N/A

Test Plan

  1. Go to Explore
  2. Choose a city (Chicago or New York)
  3. Click on any dataset
  4. Click on Visualize tab
  5. Change to map
  6. It should zoom in whichever city of the dataset that you choose on step 2 (only works for Chicago and New York for now)

Checklist Before Requesting a Review

  • I have performed a self-review of my code
  • My code follows the Style Guidelines and Best Practices outlined in the project wiki
  • I have commented my code, particularly in hard-to-understand areas
  • I have made changes to the documentation, if applicable
  • My change generates no new warnings or failed tests
  • If it is a core feature, I have added thorough tests
  • I have implemented analytics, if applicable

Copy link
Contributor

@jps327 jps327 left a comment

Choose a reason for hiding this comment

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

This is fantastic, thank you! I've tested it and it works for Chicago.

Could you please address the comments I've left? In summary there are two things to change:

  1. Let's hard code the coordinates in portal_configs.json so that we keep all hardcoded values to a single file.
  2. Let's set a default coordinate of [0, 0] and zoom the map out when a hardcoded coordinate could not be found.

@@ -101,7 +102,7 @@ export function MapViz({ dataframe }: Props): JSX.Element {
accessToken: process.env.REACT_APP_SCOUT_MAPBOX_API_KEY ?? '',
container: 'map',
style: 'mapbox://styles/mapbox/light-v11',
center: [-73.95, 40.72],
center: coordinate[city as keyof typeof coordinate],
Copy link
Contributor

Choose a reason for hiding this comment

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

If city does not exist in coordinate this returns undefined which causes Mapbox to error. We should still have a default value for that case. A common solution would be to default to [0, 0] and change the zoom value to zoom out and show the whole map - this is the most common approach to showing an 'empty' map.

@@ -0,0 +1,10 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great - would it be possible to include these in src/portal_configs.json instead and read the values from there? That way we don't have two different files of constants for each city.

@minhnguyenxuan60
Copy link
Contributor Author

Hi Juan, thank you for reviewing my pull request. I have changed my code as you requested. Please tell me if there is anything else that I need to change.

Copy link
Contributor

@jps327 jps327 left a comment

Choose a reason for hiding this comment

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

Thank you, this is great! This will be in the next release

@jps327 jps327 merged commit 9b0c7f5 into tsdataclinic:develop Aug 24, 2023
1 check passed
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.

2 participants