Hi, 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 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.
answered 04 Mar '13, 14:55 gormo Thank you. Actually I tried this using javascript but its fail. check this code please: $(document).ready(function() { var url='http://overpass.osm.rambler.ru/cgi/interpreter?data=[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
1
@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 ♦
2
$.getJSON(..) needs the success function in its third argument: http://api.jquery.com/jQuery.getJSON/ The call itself and standalone returns JSON.
(05 Mar '13, 08:18)
Roland Olbricht
1
Here is an Example that works for me: http://pastebin.com/rfQgCPtZ . 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 http://wiki.openstreetmap.org/wiki/Commercial_OSM_Software_and_Services. answered 04 Mar '13, 13:45 Hendrikklaas 3
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
|