Reverse Geocode
A Module to Transform Coordinates into Human-Readable Location Data. This module utilises the Google Maps Geocoding API.
Installation
npm install @devkosta/reverse-geocode --save-dev
yarn add @devkosta/reverse-geocode
How to Use
import { reverseGeocode } from '@devkosta/reverse-geocode';
/**
* @param {string} apiKey
* @param {number} lat
* @param {number} lng
*
* @returns {Promise}
*/
reverseGeocode('YOUR GOOGLE API KEY', 38.8977, 77.0365)
.then((res) => {
const formattedAddress = res.results[0].formatted_address;
console.log(formattedAddress);
})
.catch((error) => {
console.error(error);
});
Props
Property | Type | Required? | Description |
---|---|---|---|
apiKey | String | ✓ | Your Google API KEY. This can be retrieved from here. |
lat | Number | ✓ | The latitude value to be parsed. |
lng | Number | ✓ | The longitude value to be parsed. |
License
MIT © DevKosta