Giter Site home page Giter Site logo

codewritingcow / hrnyc20-mvp-map-app Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 18.38 MB

Interactive online map of gun homicides in New York City

Home Page: https://nyc-gun-homicide-map.herokuapp.com

License: MIT License

HTML 28.16% JavaScript 71.84%
leaflet maps javascript homicide nyc nyc-opendata guns heroku

hrnyc20-mvp-map-app's Introduction

NYC Gun Homicide Map Screenshot

NYC Gun Homicide Map

This repository contains the source for a Leaflet.js map displaying locations of gun homicides in New York City for the current year.

Each map marker contains an incident date, location and demographic information of victim and suspect. Data comes from an NYPD dataset on shooting incidents.

A dropdown menu allows users to display gun homicides by year (2006 to present).

The repository also contains the code for a Node.js server, which fetches incident data from the Socrata Open Data API. The server then returns the data to the map. The live server is hosted on Heroku.

This map was a MVP project for Hack Reactor NYC Cohort 20.

Requirements

External API Key

Key Dependencies

TODO

  • When user clicks a marker, the app displays URLs to news stories related to the incident.

Author

Gary Pang - garypang.dev

References

hrnyc20-mvp-map-app's People

Contributors

codewritingcow avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar

hrnyc20-mvp-map-app's Issues

Map not displaying current year homicides

Bug

The map is showing the "Number of Gun Homicides in 2022" (the current year) as zero. It is also not loading any map markers of homicide locations.

However, the map still shows the correct number and map markers for previous years.

The problem is due to an update to the API for current-year shooting incidents. The URL param statistical_murder_flag originally had a value of true or false, but now the value is either Y or N.

When the map app requests data for incidents where statistical_murder_flag matches true, the API finds no matches. Therefore, the API returns an empty array as the response to the map app. See screenshots of data response:

Screen Shot 2022-06-19 at 12 59 44 PM

Screen Shot 2022-06-19 at 12 59 50 PM

Solution

Caveat

To add to the confusion, the API for historic shooting incidents still uses true or false for statistical_murder_flag

Upgrade Leaflet to v1.8.0

The gun homicide map is still using Leaflet v1.4.0. Let's upgrade to the latest version (v1.8.0).

Save search results to database

Add database to Heroku dyno, and save search results to the DB. This decrease the number of HTTP requests sent to the NYC Open Data API. See issue #10, "Improve server speed with Redis caching."

Display URLs to news stories

When users click a map marker, the app should display URLs to news stories about the incident.

The URLs would have to be stored in a database.

On the NYC Open Data API, each incident has a unique INCIDENT_KEY. That key can be used as a reference key in the database for the map app.

Improve server speed with Redis caching

Implement Redis to decrease the number of HTTP requests sent to the NYC Open Data API.

When users view homicides for a selected year, the server should look for those records in the Redis cache first. If the records aren't cached, the server should query the Web app's database.

If the DB doesn't have those records, only then should the server send a GET request to the external API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.