![Alt-Text](https://private-user-images.githubusercontent.com/74965926/241815147-bf431a7d-09a4-4e45-ac4e-a952580730ad.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIzNTM0MzYsIm5iZiI6MTcyMjM1MzEzNiwicGF0aCI6Ii83NDk2NTkyNi8yNDE4MTUxNDctYmY0MzFhN2QtMDlhNC00ZTQ1LWFjNGUtYTk1MjU4MDczMGFkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMwVDE1MjUzNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNmYzE3N2I4NzdhODM0YTc0ODg1ZjY2ZWViYWRlN2FiNzRkOGVmMDcwMjNhOWRkM2ZkOTZlZWMzYjFhM2ZhMzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.fZYA2fsM1IgoJVxCQflNRcX55b3Smm7XeXLSYBW-kDs)
Welcome to a demo showcasing the usage of Datamaps without frameworks like Node.js or React.
The data utilized for this demo is sourced from mledoze. You can find the data content at the following location: countries.json, is available under the Open Database License (ODbL). File is included.
To avoid unnecessary traffic and direct requests to the mledoze repository every time the demo is accessed, I have created a C# script.
This script fetches the data once and generates a static file with the desired properties, which can be directly used in the demo without relying on live requests to the mledoze repository.
public class Country
{
public Name name { get; set; } = new();
public string cca2 { get; set; } = string.Empty;
public string cca3 { get; set; } = string.Empty;
public string ccn3 { get; set; } = string.Empty;
public double[] latlng { get; set; } = Array.Empty<double>();
public string[] borders { get; set; } = Array.Empty<string>();
public string flag { get; set; } = string.Empty;
}
public class Name
{
public string common { get; set; } = string.Empty;
public string official { get; set; } = string.Empty;
}
using HttpResponseMessage response = await client.GetAsync("https://raw.githubusercontent.com/mledoze/countries/master/dist/countries.json");
var countries = JsonConvert.DeserializeObject<List<Country>>(json);
if (countries is not null)
{
sw.WriteLine("var data = {");
countries.ForEach(x =>{
if (countries.IndexOf(x) > countries.Count - 2)
{
sw.WriteLine(x.cca3 + ":{");
sw.WriteLine($"Label:\"{x.name.common}\",");
sw.WriteLine($"Latitude:{x.latlng[0]},");
sw.WriteLine($"Longitude:{x.latlng[1]}");
sw.WriteLine("}");
/*Fun fact: prettifier appends comma anyways -.- */
}
else if (countries.IndexOf(x) < countries.Count - 2)
{
/*same as above but with a comma to seperate entries*/
sw.WriteLine("},");
}
});
sw.WriteLine("}");
}
This demo is built exclusively using static web technologies such as HTML, CSS, and JavaScript. It doesn't rely on specific frameworks but rather incorporates libraries and resources through CDNs (Content Delivery Networks) or by directly including them as static files.
By taking this approach, the demo remains lightweight and independent of specific frameworks while leveraging the functionalities provided by external libraries. This enables efficient and flexible development by leveraging core web technologies and integrating the benefits of libraries through CDNs or static files.
Feel free to explore the demo by visiting the GitHub Pages associated with this project.