What is this? The Washington Post hosts and updates a .csv file tracking every fatal police shooting in the US since January 2015. My code reads that file and places every victim’s name, date, and location on a Google Map for the last 3 months. Hover over a map marker to see info about the victim(s).
Why? Yeah, it’s a morbid subject, but I chose it because it’s a constantly changing dataset I can use to show my ability to use JS/jQuery in cross-server AJAX calls, data crunching, third-party APIs/libraries, and so on.
How does it work?
- Gets the shootings data file from Github via AJAX, which is parsed using Papa Parse JS library.
- Narrows the data to the last 3 months.
- Imports and parses a locally-stored .csv file linking cities to coordinates, since Google Maps requires latitude/longitude coordinates to place a marker rather than just a city name.
- Generates the map, then places a marker for each city.
- Allow the user to change the number of months of data displayed, or enter start and end dates, and refresh the map.
Note: The cities.csv file is large but is missing several towns, and it keys off of zip code rather than city/state pair, resulting in duplicates. Currently, those are written to the JS console and otherwise skipped.