You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Juan Camilo Guarin Peñaranda 1408549fa7
Update README.md
3 years ago
.idea feat: add lookup request 4 years ago
.vscode first version 6 years ago
dist type: restore INominatimResult type for backward compatibility 4 years ago
examples feat: add lookup request 4 years ago
repo Added Patreon image link 5 years ago
.gitignore feat: add lookup request 4 years ago
README.md Update README.md 3 years ago
index.ts type: restore INominatimResult type for backward compatibility 4 years ago
package-lock.json type: more precise place types 4 years ago
package.json type: more precise place types 4 years ago
tsconfig.json fix(#2): error due to using http instead of https -> build 5 years ago

README.md

REPO MOVED.

Please refer to https://github.com/owsas/opensource for the latest version. Thank you.

Nominatim-JS

Unofficial JS SDK for the Nominatim Open Street Map service that allows geocoding and reverse geocoding

How to use?

First, install the SDK

$> npm install --save nominatim-JS

Then, use it :). It works with Promises, or can be used with async / await.

const { NominatimJS } = require('nominatim-js');

Example with promises

NominatimJS.search({
  q: 'bakery in new york'
}).then(results => {
  // do something with results
}).catch(error => {
  // error ocurred
})

Example with async / await

async function search(){
  let results = await NominatimJS.search({
    q: 'bakery in new york'
  });
}

NOTE: To await the response, the call to the API must be written inside an async function

Lookup

First parameter is an array of OSM ids with types. Type can be one of way, node or relation.

Second parameter is optional params.

Example with promises

NominatimJS.lookup([{ type: "way", id: 163993703}])
  .then(results => {
    // do something with results
  })
  .catch(error => {
    // error ocurred
  })

Example with async / await

const results = await NominatimJS.lookup([{ type: "way", id: 163993703}]);

Typescript

Typescript is supported out of the box.

const idToLookup: IOsmId = { type: "way", id: 163993703};
const lookupParams: ILookupParams = { addressdetails: 1 };
const results: ISearchResult[] = await NominatimJS.lookup([idToLookup], lookupParams);

More examples

See examples folder in the repository

Author

Juan Camilo Guarín Peñaranda
Otherwise SAS
Colombia

License

MIT

Support us on Patreon

patreon