gcoords

1.0.0 • Public • Published

GCoords

A tiny NPM module for looking up coordinates from an address. Relies on the Google Maps web API. You will need to get a key here. The only dependency is the native https module for making the request.

Usage

Import it into your project:

const gcoords = require("gcoords");

Initialize with an API key:

gcoords.init(<YOUR_API_KEY>);

Lookup location's coordinates:

gcoords.getCoords("Rome, Italy").then((result) => {
    console.log(result);
});

Lookup coordinates' address:

gcoords.getLocation(["40.714224","-73.961452"]).then((result) => {
    console.log(result);
});

Both functions support a second parameter - the data format. If left blank, the default is json. Some examples:

gcoords.getLocation(["40.714224","-73.961452"],"json").then((result) => {
    //Will return JSON
});
 
gcoords.getLocation(["40.714224","-73.961452"]).then((result) => {
    //Will also return JSON
});
 
gcoords.getLocation(["40.714224","-73.961452"],"xml").then((result) => {
    //XML because why not...
});

Roadmap

  • JSON support
  • XML support
  • Coordinates to location
  • Error handling/address cleanup/validation
  • Multiple results
  • Clean up the code
  • Promises
  • Push to NPM

Package Sidebar

Install

npm i gcoords

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

5.37 kB

Total Files

3

Last publish

Collaborators

  • ivanempire