iso-by-coords

Get a country's ISO code by coordinates

Usage no npm install needed!

<script type="module">
  import isoByCoords from 'https://cdn.skypack.dev/iso-by-coords';
</script>

README

iso-by-coords

npm NPM David

Usage

TypeScript

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

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]