SHARE
TWEET

OSM jquery JSONP

a guest Mar 5th, 2013 257 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script src="http://code.jquery.com/jquery-latest.js"></script>
  5. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  6. </head>
  7. <style type="text/css">
  8.   .invisible { display: none }
  9. </style>
  10. <body>
  11. <div id="log">
  12. </div>
  13. <hr>
  14. <table id="results">
  15. <tr><th>Name</th><th>lat</th><th>lon</th></tr>
  16. </table>
  17. <form><input type="button" id="b" value="Laden"/></form>
  18. <script>
  19. handleOSMResponse = function(data) {
  20.         $("#b").addClass("invisible");
  21.     $.each(data.elements, function(idx, obj) {
  22.       $("<tr><td>"+ obj.tags.name + "</td><td>" + obj.lat +"</td><td>"+obj.lon+"</td></tr>").appendTo("#results")
  23.     });
  24. }
  25.  
  26. $("#b").click(function() {
  27. $("#b").val("Loading...");
  28. $.getScript('http://overpass.osm.rambler.ru/cgi/interpreter?jsonp=handleOSMResponse&data=[out:json];node[amenity=restaurant](50.7,7.1,50.8,7.25);out;');
  29. });
  30.  
  31. </script>
  32. </body>
  33. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top