1.0.0 • Published 6 years ago

gcoords v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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