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



Is the only way to use OSM Data by downloading them? There's anyway to use the data with javascript via API without the need to download Data? if yes can you provide me with any example please. Thank you

asked 04 Mar '13, 12:53

Berjawi's gravatar image

accept rate: 0%

edited 04 Mar '13, 20:45

aseerel4c26's gravatar image

aseerel4c26 ♦

You can also use for example the overpass API to get all restaurants in a given geographic area as a JSON-formatted object, and then process this object using JavaScript. Is that what you want to do?

You would need to know the key-Value-combination(s) of your objects of interest and the lat/lon coordinates of the bounding box in which to search.[out:json];node[amenity=restaurant](50.7,7.1,50.8,7.25);out;
permanent link

answered 04 Mar '13, 14:55

gormo's gravatar image

accept rate: 13%

edited 04 Mar '13, 14:56

Thank you. Actually I tried this using javascript but its fail. check this code please: $(document).ready(function() { var url='[out:json];nodeamenity=restaurant;out;'; $('#myBtn').click(function(){ $.getJSON(url, function(data) { alert('success');}).success(function(){alert('second success');}).error(function(){alert('error');}); }); });

I dont know why the result is always error !!

(04 Mar '13, 15:48) Berjawi

you are missing square brackets [ ] around amenity=restaurant

(04 Mar '13, 16:10) gormo

@gormo: they were eaten by MarkDown. The code should have been written in a new line and indented by a space to display it as it is.

(04 Mar '13, 20:30) aseerel4c26 ♦

$.getJSON(..) needs the success function in its third argument:

The call itself and standalone returns JSON.

(05 Mar '13, 08:18) Roland Olbricht

Here is an Example that works for me: . It's using JSONP, cause I could not get pure JSON running consistently because of the same origin policies(probably).

(05 Mar '13, 14:58) gormo

Dear Berjawi, What do you mean by using OSM data ? There some protocols at the Wiki for commercial or any other use, but youre question needs some extra data to made clear whats behind your question. Take for instance a look here

permanent link

answered 04 Mar '13, 13:45

Hendrikklaas's gravatar image

accept rate: 5%


Hi, thank you for you answer. Here's a sample example : I want to search all restaurant near a given location, but I'll not display the data on a map, I just want to use the data on my code, lets tell display data as text.

What I understand from the wiki , that I can use API to search and download Data to my local, then put the data into a database and finally use data in the code from my database. there's any other way?

(04 Mar '13, 13:51) Berjawi

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 04 Mar '13, 12:53

question was seen: 12,582 times

last updated: 05 Mar '13, 14:58

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