reversegeocode-to-zip

1.0.7 • Public • Published

reversegeocode-to-zip

npm version

Uses Google's geocoding API to convert longitude and latitude to a zipcode. Requires supplying a google maps API key.

Installation

yarn add reversegeocode-to-zip

or

npm i reversegeocode-to-zip

Example

import reverseGeocode from "reversegeocode-to-zip"

const region = {
      latitude: 36.98823868538418,
      longitude: -122.00553903356194,
};

const GOOGLE_API_KEY = "123123";

reverseGeocode(region, GOOGLE_API_KEY)
  .then(zipcode => console.log(zipcode))
  .catch(err => console.log(err));

Note: don't actually put your API key in your code. Import it as an environment variable.

Testing

Clone repo:

git clone https://github.com/osamaq/reversegeocode-to-zip.git && cd reversegeocode-to-zip

Install dependencies (jest):

yarn

or

npm i

Run tests:

yarn test

or

npm test

Todo

  1. Write tests.

/reversegeocode-to-zip/

    Package Sidebar

    Install

    npm i reversegeocode-to-zip

    Weekly Downloads

    3

    Version

    1.0.7

    License

    ISC

    Unpacked Size

    3.72 kB

    Total Files

    4

    Last publish

    Collaborators

    • osamaq