COVID-19 realtime US county maps

Following up on the latest articles about this covid-19, in this example we use the awesome NovelCovid API to get data for each state in the US to populate individual state maps with county data. Here’s an example for Alabama:

You can download the export file here.

You will need to add the code below to the custom JS field and change the number in igm_custom_filter_20997 to the ID of your map. And where it says “Alabama” you would need to change it to the state you’re currently displaying.

More detailed will follow below.

function igm_custom_filter_20997(data) {
data.regions = data.regions.filter(function(region){
return region.province == "Alabama";
});
data.regions.map(function(region){
Object.assign(region, region.stats);
});
return data;
}

Setting up Regions

In this map we setup the regions to have a custom data source, an external JSON file generated by the API with the information for all US counties: https://corona.lmao.ninja/v2/jhucsse/counties

COVID-19 realtime US county maps

Setting Up Tooltip and Heatmap information

For the tooltip template, we added the following:

<strong>{county}</strong> <br> Confirmed: {confirmed} <br> Deaths: {deaths}

And in the Heatmap configurations we used the ‘confirmed’ information as the source:

COVID-19 realtime US county maps

Custom Callback

In order to get the information to work properly, we need to write a custom callback function to format the data and only retrieve the data from a specific state. The code used was already mentioned above.

COVID-19 realtime US county maps

Remember to change the “20997” from the code above, with the ID of your map for it to work properly. And change the state name to the one you’re building.

Feel free to leave a comment below if you have any question.

blank

Posted by Carlos Moreira

Lead developer of Interactive Geo Maps plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *