GithubHelp home page GithubHelp logo

nominatim's Introduction

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');

Search

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

nominatim's People

Contributors

jalilarfaoui avatar jcguarinpenaranda avatar skyroller5 avatar srghma avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nominatim's Issues

Error due to using http instead of https

Failed to load http://nominatim.openstreetmap.org/search?q=bakery%20in%20new%20york&format=json: Redirect from 'http://nominatim.openstreetmap.org/search?q=bakery%20in%20new%20york&format=json' to 'https://nominatim.openstreetmap.org/search?q=bakery%20in%20new%20york&format=json' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://vdare_feature_tests_be:3000' is therefore not allowed access.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.