Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/supersoniko/iso-by-coords

NPM package to get a Country's ISO code by coordinates
https://github.com/supersoniko/iso-by-coords

Last synced: about 5 hours ago
JSON representation

NPM package to get a Country's ISO code by coordinates

Awesome Lists containing this project

README

        

# iso-by-coords

![npm](https://img.shields.io/npm/v/iso-by-coords)
![NPM](https://img.shields.io/npm/l/iso-by-coords)
![David](https://img.shields.io/david/supersoniko/iso-by-coords.svg)

## Usage

### TypeScript

```javascript
import configureCountryIso from 'iso-by-coords';
import {CountryISO} from 'iso-by-coords/lib/typings';
import getMap from 'countries-maritime-10m-extended';

const {getIsoCodes: getIsoCodesAlpha2} = configureCountryIso({
iso: CountryISO.ALPHA_2,
map: getMap()
});

const {getIsoCodes: getIsoCodesAlpha3} = configureCountryIso({
iso: CountryISO.ALPHA_3,
map: getMap()
});

getIsoCodesAlpha2(50.95148037338329, 5.350969164113395); // returns [BE]
getIsoCodesAlpha3(50.95148037338329, 5.350969164113395); // returns [BEL]
```

### JavaScript

```javascript
const configureCountryIso = require('iso-by-coords').default;
const getMap = require('countries-maritime-10m-extended');

const {getIsoCodes: getIsoCodesAlpha2} = configureCountryIso({
iso: 'A2',
map: getMap()
});

const {getIsoCodes: getIsoCodesAlpha3} = configureCountryIso({
iso: 'A3',
map: getMap()
});

getIsoCodesAlpha2(50.95148037338329, 5.350969164113395); // returns [BE]
getIsoCodesAlpha3(50.95148037338329, 5.350969164113395); // returns [BEL]
```