For this example, we will render the country layer by styling each country based on income level by associating its country code to income level data provided by the world bank. There are quite a few brackets; so, we've simplified it to four levels: high
, medium
, low
, and poor
. We'll draw each country in a color associated with its income level based on these brackets. Let's start from the previous example.
At the beginning of the
<script>
tag, before anything else, we will define colors for the four brackets. Use any colours you like:var high = [64,196,64,1]; var mid = [108,152,64,1]; var low = [152,108,64,1]; var poor = [196,32,32,1];
The income levels for each feature are indicated by a code. We need a way to look up the color to use for each code. You don't need to include the comments, they are there to show how we are grouping the income levels:
var incomeLevels = { 'HIC': high, // high income 'OEC': high, // high income OECD...