postlib
v1.0.1
Published
NPM Package to resolve Libyan Post Addresses to GPS Coordinates and Google Plus Codes
Downloads
1
Readme
PostLib
This package is a javascript library used to resolve Libya Post addresses into GPS coordinates and Google Plus Codes.
Installation
npm install postlib
Usage
Using npm to include postlib in your own project:
npm install postlib
Import it in your JavaScript/typescript file:
import { postly } from 'postlib';
To resolve the postal address to GPS coordinates (e.g. address 10.10.10) call the function addressToCoordinates
async function getGPSCoordinates(address: string) {
try {
let response = await postly.addressToCoordinates(address);
// response => {long: 32.88106805800004, lat: 13.168020317000071, address: "10.10.10"}
} catch(err) {
// error handling
}
}
To resolve the postal address to Google Plus Code(e.g. address 10.10.10) call the function addressToPlusCode
async function getPlusCode(address: string) {
try {
let response = await postly.addressToPlusCode(address);
// response => {address: "10.10.10", gpluscode: "8F4MV5J9+C6"}
} catch(err) {
// error handling
}
}
To validate if the supplied address of a valid format use the function isAddressValid
function validAddress(address: string) {
retrun postly.isAddressValid(address); // returns true or false
}