gcoords
v1.0.0
Published
NPM module to look up a city's coordinates and vice versa
Downloads
9
Maintainers
Readme
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
- [x] JSON support
- [ ] XML support
- [x] Coordinates to location
- [ ] Error handling/address cleanup/validation
- [ ] Multiple results
- [ ] Clean up the code
- [x] Promises
- [ ] Push to NPM