function chartmap(data, mapContainer) {
const map = L.map(mapContainer).setView([20, 0], 2);
fetch("https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json")
.then(response => response.json())
.then(worldData => {
L.geoJSON(worldData, {
style: feature => {
const countryName = feature.properties.name;
const countryData = data.find(d => d.countryName == countryName);
const airportCount = countryData ? countryData.count : 0;
const fillColor = airportCount > 1000 ? "#800026"
: airportCount > 500 ? "#BD0026"
: airportCount > 200 ? "#E31A1C"
: airportCount > 100 ? "#FC4E2A"
: airportCount > 50 ? "#FD8D3C"
: airportCount > 10 ? "#FEB24C"
: airportCount > 0 ? "#FED976"
: "#FFFFFF";
return { fillColor, weight: 1, color: "#333", fillOpacity: 0.7 };
},
onEachFeature: (feature, layer) => {
const countryName = feature.properties.name;
const countryData = data.find(d => d.countryName == countryName);
const airportCount = countryData ? countryData.count : 0;
layer.bindTooltip(`${countryName}: ${airportCount.toLocaleString()}`, { sticky: true });
}
}).addTo(map);
});
return map
}