Can you do this. If you do not need more accuracy, you can use the table with the coordinates of the countries. And determine the nearest coordinate of the country. But this is bad.
A good solution is that you get a KML file with country borders. But you need a good algorithm to determine which country you are in. The algorithm for finding the position of a point and a polygon is described here . There are also answers to stackoverflow 1 , 2 , but this is for an airplane.
It is also possible to pre-calculate countries for coordinates using a small step (for example, 30 '') and determine coutry by finding the nearest pre-calculated point to your point. You can pre-enroll the country with many online services.
source share