NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I developed an open-source APP in Cordova (it uses Javascript) and I'm using the Google Maps API, though as the APP is becoming popular my bill is increasing (not nice for a free, ad-free APP). Thus I'd like to move to Open Street Maps.

I've been reading the docs about the Overpass API but I see no simple clear examples of code implementation. I know the sever to use, that I should use HTTP GET requests and use their special XML syntax. But it's not clear how do I pass that XML to the GET request. Furthermore the examples regarding coordinates provides as input a boundary box, not a point (or a point is considered as a square whose corners are the same?).

Could you kindly provide a simple example in Javascript (for example with $.ajax) on how to get the address of a certain location by providing the geo-coordinates to the API?

asked 06 Mar '21, 14:23

Jo%C3%A3o's gravatar image

João
31226
accept rate: 0%

edited 06 Mar '21, 16:39

Spiekerooger's gravatar image

Spiekerooger
3.1k22356


What you are looking for is reverse geocoding. This is rather a job for Nominatim - see https://nominatim.org for documentation. And there you can use json responses that are much easier for you to use. Please respect the nominatim usage policy - to be found here: https://operations.osmfoundation.org/policies/nominatim/ . It's maybe not a good idea to hardcode the nominatim endpoint operated by osm into an app. So maybe you would have to install your own nominatim instance or use one of the providers listed here: https://wiki.openstreetmap.org/wiki/Nominatim#Alternatives_.2F_Third-party_providers .

permanent link

answered 06 Mar '21, 16:36

Spiekerooger's gravatar image

Spiekerooger
3.1k22356
accept rate: 16%

edited 06 Mar '21, 16:42

Thanks a lot, what do you think about my solution? https://github.com/jfoclpf/form-for-parking-violation/issues/85 and yes, I will respect the usage policy, surely much less than 1 request per second. Right now my APP has something like 2000 requests per month

(06 Mar '21, 19:06) João

Looks good. I would add a version number to your User-Agent string, e.g.

xhr.setRequestHeader('User-Agent', 'com.form.parking.violation v0.1');

And 2000 a month does not sound like too much. But then versioning helps if the app gets more users and you have to change sth if v0.1 gets to many requests.

Please don't don't forget to accept the answer with the nominatim hint above if that helped.

(06 Mar '21, 19:37) Spiekerooger

Thanks again, I also shared the result in Stackoverflow: https://stackoverflow.com/a/66509433/1243247

(07 Mar '21, 13:11) João

btw, I realized now I can't change the http request headers (browsers won't allow it). May I use instead other means of ID, for example the email address such as seen here?

(07 Mar '21, 14:11) João

Based on the answers above I am able to get the information I need. But I want to do this the right way, within the guidelines. What do I need to do for my app, should I apply for permission, request a special kind of commercial account, pay for it, how? Thanks in advance :)

(05 Jan '23, 16:42) freestyle212

@freestyle212: for internal testing or if you have a really small usage footprint, you may follow the guidelines as described in the Nominatim usage policy. If you do want to use it for a business use case or commercial application, you should either run your own nominatim instance or use one of the third party providers listed here: https://wiki.openstreetmap.org/wiki/Nominatim#Alternatives_.2F_Third-party_providers

(05 Jan '23, 16:47) Spiekerooger
showing 5 of 6 show 1 more comments

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×689
×85
×85
×36

question asked: 06 Mar '21, 14:23

question was seen: 32,125 times

last updated: 05 Jan '23, 16:47

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum