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.

US Map for COVID-19 in WordPress

If you’re using this plugin to build a map to report on the number of cases of the new coronavirus disease (COVID-19), following up on the latest article showing how you could create a map of the world using real-time data from external sources, in this example I’ll provide some custom code to build a US specific heat map.

We use data made available by NovelCovid API.


Most of the technical details are described in the previous post. We’ll jump straight to the important details. If you’re using the plugin, you can download the export file for the map above.

This map is just an example, you can do this to any country or even county maps if you have the data available. You can also add the data manually instead of reading from the external source.

If you have any question about this, leave a comment below or contact me.

Display specific US States only

If you need to build a map where only some states of the US display, you can use this plugin to achieve that. You’ll simply need to select the normal US map and then use the option to specify which regions you want to use.


In this example we specified some of the states in the east cost as the only regions to display on the map.

Display specific US States only

This technique works for any country and you can specify any of the available regions on the chosen map. You can also do the opposite and specify which regions to exclude.


And the good news is that this feature is part of the free version!