{
let currentGADM = 'gadm0';
let data = gadm0;
let container = html`<div id='map'></div>`;
let legend = html``;
let matchExpression = null;
let matchExpressionGADM2 = null;
let content = html`
<div class='map-wrapper'>
${container}
<div class='map-overlay' id='features'>
<h2>The PM2.5 values of </h2>
<div id='country'>
<p>${year}</p>
</div>
</div>
${legend}
</div>
`;
yield content;
const key = dataLookup[dataType] + year;
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v10',
center: [15, 23.5],
zoom: 1,
});
map.on('load', () => {
map.addSource('countries', {
type: 'vector',
url: 'mapbox://mapbox.country-boundaries-v1',
});
map.addSource('aqli-tileset', {
type: 'vector',
url: 'mapbox://fndvit.aqli-test',
});
const key = dataLookup[dataType] + year;
matchExpression = matchExpressionOptions['gadm0'].match;
for (const row of data) {
const color = colorPalette[dataType][1](row[key]);
matchExpression.push(row[matchExpressionOptions[currentGADM].row], color);
}
matchExpression.push('#F2F2AD');
map.setPaintProperty('countries-join', 'fill-color', matchExpression);
matchExpressionGADM2 = matchExpressionOptions['gadm2'].match;
for (const row of gadm2) {
const color = colorPalette[dataType][1](row[key]);
matchExpressionGADM2.push(row[matchExpressionOptions['gadm2'].row], color);
}
matchExpressionGADM2.push('#F2F2AD');
map.setPaintProperty('county-join', 'fill-color', matchExpressionGADM2);
map.addLayer(
{
id: 'countries-join',
type: 'fill',
source: 'countries',
'source-layer': 'country_boundaries',
maxzoom: zoomThreshold['gadm2'],
paint: {
'fill-color': matchExpression,
},
},
'admin-1-boundary-bg'
);
map.addLayer(
{
id: 'county-join',
type: 'fill',
source: 'aqli-tileset',
'source-layer': 'aqli-test',
minzoom: zoomThreshold['gadm2'],
paint: {
'fill-color': matchExpressionGADM2,
},
},
'admin-1-boundary-bg'
);
})};