Given longitude and latitude, how can I get the code and name of a country?
From this source I have obtained the following data that correspond to the latitude and longitude of countries. How can I get the name and code of the country in which some coordinates are located?
[
{
"countryCode": "AD",
"latitude": "42.546245",
"longitude": "1.601554",
"countryName": "Andorra"
},
{
"countryCode": "AE",
"latitude": "23.424076",
"longitude": "53.847818",
"countryName": "United Arab Emirates"
},
{
"countryCode": "AF",
"latitude": "33.93911",
"longitude": "67.709953",
"countryName": "Afghanistan"
},
{
"countryCode": "AG",
"latitude": "17.060816",
"longitude": "-61.796428",
"countryName": "Antigua and Barbuda"
},
{
"countryCode": "AI",
"latitude": "18.220554",
"longitude": "-63.068615",
"countryName": "Anguilla"
},
{
"countryCode": "AL",
"latitude": "41.153332",
"longitude": "20.168331",
"countryName": "Albania"
},
{
"countryCode": "AM",
"latitude": "40.069099",
"longitude": "45.038189",
"countryName": "Armenia"
},
{
"countryCode": "AN",
"latitude": "12.226079",
"longitude": "-69.060087",
"countryName": "Netherlands Antilles"
},
{
"countryCode": "AO",
"latitude": "-11.202692",
"longitude": "17.873887",
"countryName": "Angola"
},
...
]
Full dataset https://jsfiddle.net/kmznxrhe/
For example, given the following coordinates Latitude: 12.4157952, Longitude: -86.8777984, how can I obtain the name and code of the country in which those coordinates are located?
I do not share an example because I do not really know how to do this task
Thanks in advance