This project is to map the novel Corona Virus infections data and depict the global impact on the Google Maps.
For demo: [Demo deployment no longer active] - Please build and run locally.
The approach is kept simple:
- Get the CoVID data from an API Endpoint
- Store this data in Firebase RTDB
- Create a Google Map instance
- Leverage the CoVID Data and create overlays, using @deck.gl libraries
Regular Updates:
Instead of using the web client to call the API Endpoint, here the approach is to make the web client depend on the Firebase RTDB for data (there is a good reason for this). Use the Cloud Functions to call the API Endpoint every 3 hours and update the data in RTDB.
Why do we do this?
On the map for every affected location, we need the following fields:
- Latitude
- Longitude
- (optional) Country's Flag
This data is not available in the dataset from the API. Thus, the file src/countries.json
has the list of all countries with their lat-lng and flag (emoji). Thanks to https://getemoji.com/
The countries_stat
(covid data) from the API and the location data from the countries
are combined to create the required source_data
for the overlays on the Google Map.
Clone this repository and run npm install
https://developers.google.com/maps/documentation/javascript/get-api-key
Update the src/config.js
with the API Key.
For API Key restrictions, refer: https://cloud.google.com/docs/authentication/api-keys#api_key_restrictions
Signup (FREE) and get the API Key to access the CoVID Data API. https://rapidapi.com/astsiatsko/api/coronavirus-monitor
Update the functions/src/api-key.ts
Signup/Login (Google ID) for Firebase and create a project. Refer: https://firebase.google.com/docs/web/setup
After you setup the Firebae Project, get the Firebae Config and update src/config.js
Please install firebase cli
to run any firebase commands. Refer: https://firebase.google.com/docs/cli
Ensure you've followed Firebase Project setup and have run firebase init
command to setup the following:
- Realtime Database
- Cloud Functions
- Hosting
Double check that your Hosting project is setup with a proper site name and ensure the same is updated in firebase.json
file.
...
"hosting": {
"site": "map-covid-19",
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
...
In this example the site name is referred as map-covid-19
- you can name whatever name you like during the hosting setup on Firebase Console.
The countries
node should be setup with the data from src/countries.json
. For this, run npm run setup-countries
script. This will populate the RTDB at /covid-19/countries
data node.
On the terminal change to functions
folder and do npm install
$ cd functions
$ npm install
...
Build
Run npm run build
- webpack will build the project.
Deployment of this project is done in two steps:
- Cloud Functions: Run
npm run deploy:functions
to deploy the cloud functions - Hosting: Run
npm run deploy:hosting
to deploy the cloud hosting
Running locally If you wish to run the project locally, follow the steps:
- Ensure the
countries
is setup on RTDB - refer to RTDB Setup above. - Deploy the cloud functions and let it start (check the console, to ensure the CoVID Data is updated)
- Run
npm start
to start the local webpack dev server
Note: If you've setup GMap API Key restrictions, ensure
localhost
is enabled.
WebGL powered Data Visualization library. https://deck.gl/
- Jeff Delaney (https://fireship.io) - He has created fantastic courses, tutorials, short videos, code snippets and special mention: https://fireship.io/lessons/deckgl-google-maps-tutorial/
- Marco Predari for his inspiration to create this project. Link to Predo's project: https://covid19.marcopredari.it/
- @astsiatsko (https://rapidapi.com/user/astsiatsko) for providing the Data API for FREE
I wish the CoVID-19 spread stops soon and all the humanity settles down with normal life. I also take this moment to thank all the people who've been selflessly supporting, assisting, treating, managing the emergency support systems, healthcare facilities and also normal people like you and me who've quarantined themselves to be just safe.
@author: Prasanna Neelavar