Please refer to https://github.com/owsas/opensource for the latest version. Thank you.
Unofficial JS SDK for the Nominatim Open Street Map service that allows geocoding and reverse geocoding
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');
NominatimJS.search({
q: 'bakery in new york'
}).then(results => {
// do something with results
}).catch(error => {
// error ocurred
})
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
First parameter is an array of OSM ids with types. Type can be one of way
, node
or relation
.
Second parameter is optional params.
NominatimJS.lookup([{ type: "way", id: 163993703}])
.then(results => {
// do something with results
})
.catch(error => {
// error ocurred
})
const results = await NominatimJS.lookup([{ type: "way", id: 163993703}]);
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);
See examples folder in the repository
Juan Camilo Guarín Peñaranda
Otherwise SAS
Colombia
MIT