-
Notifications
You must be signed in to change notification settings - Fork 136
Bugfix - Quick map fix for null entries #108
base: main
Are you sure you want to change the base?
Conversation
Apologies for all these linting commits. ESlint was not playing ball with me today. |
...stateData.features.filter( | ||
(feature) => feature.geometry.coordinates[0] != null | ||
) |
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.
Is there a way we can ensure the stateData
on the store's end is clean from the store's level? It may not be helpful to have null locations in general (think of another component that uses this.$store.state.usStates.usState;
)
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.
Totally agree with you. I don't have a great idea of the project layout as I just cloned and started working on it an hour ago but I figured that list is useful with nulls because it also informs the list on the side (from what I can tell). So based on that I would imagine we still want those items to show up in the list view, just not on the map if they don't have coordinates.
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.
Actually I just realized this would break the list since it's modifying the data directly. Whoops. @Maker-Mark let me know (if you can) if my hunch was right and if so I'll change this so it uses a copied version for the map.
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 have a deep copy of this code ready to go. So if we replace the stateData assignment with
JSON.parse(
JSON.stringify(this.$store.state.usStates.usState)
);
we'll have a deep copy which keeps the unmappable items in the list but not on the map.
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'm trying to figure out where the data is being fetched from. If we can sanitize it there, we should be able to get rid of them
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.
If we just want to fix it for locations. We can just filter the list instead of splicing the data. Filter will return a new array.
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'm trying to figure out where the data is being fetched from. If we can sanitize it there, we should be able to get rid of them
Sorry just saw this. It comes from the API directly to my knowledge
await this.$http.$get(`/api/v0/states/${this.$route.params.state}.json`) |
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.
If we just want to fix it for locations. We can just filter the list instead of splicing the data. Filter will return a new array.
Agreed. I think the issue there is that we also need to pass all the metadata along with it. We can just point to the same metadata since there's no issue with store_count
being incorrect but since it's a negligible and we'd have to make that second object anyways I figured the deep copy is worth it.
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.
Just noticed this discussion after I started working on #141. I believe mapbox does not rely on metadata and I could possibly add a null check to the filteredLocationData, would that help?
This is to address #103. Not the best code in the world but concise. Removes null entries to prevent map from putting locations on "null island"
Before:
After:
I know this isn't the best JS in the world, so do let me know if mapbox or CARTO provides a better way of doing this (I couldn't find any)
Happy and excited to help!