country-iso
🗺 Get ISO 3166-1 alpha-3 country code for geographic coordinates.
Click on the map for a live preview.
Install
$ npm install --save country-iso
Usage
You can query any (lat,lng)
pair on the earth. It also works for territorial waters and disputed countries.
const countryIso = ; // Query a point in Italy.countryIso;// => ['ITA'] // Query a disputed country.countryIso;// => ['ESH', 'MAR'] // Query a point somewhere in Atlantic Ocean.countryIso;// => []
The package internally uses @geo-maps/countries-maritime map with 10m resolution.
The accuracy of the map has been tested with 23785 cities.
API
Array.<string>
get(lat, lng) ⇒ Searches for every country which contains the point (lat, lng).
Returns: Array.<string>
- Array of ISO 3166 alpha-3 country code for the geographic
coordinates.
Param | Type | Description |
---|---|---|
lat | number |
The latitude of the point. |
lng | number |
The longitude of the point. |
Authors
- Matteo Chen - chq-matteo
- Simone Primarosa - simonepri
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.