Guest User

google places api

a guest
Aug 9th, 2012
65
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function init() {
  2. document.addEventListener("deviceready", deviceready, true);
  3. }
  4.  
  5. function deviceready() {
  6. console.log('loaded');
  7.  
  8. $("#searchButton").bind("touchstart",function() {
  9. var s = $.trim($("#searchField").val());
  10. console.log("going to search for "+s);
  11.  
  12. $.getjson("https://maps.googleapis.com/maps/api/place/textsearch/json?query="+escape(s)+"&sensor=true&key=AIzaSyB9jAgjipRv4yG1Jpn95acRzcqR94nZrLo&rankby=distance", {}, function(res) {
  13. var results = res.SearchResponse.Results;
  14. if(results.length == 0) {
  15. $("#results").html("No results!");
  16. return;
  17. }
  18. var s = "";
  19. for(var i=0; i<results.length; i++) {
  20. s+= results[i].formatted_address+<br/><a href='"+results[i].Url+"'> "+results[i].DisplayUrl+"</a>";
  21. Uncaught SyntaxError: Unexpected token <
  22. }
  23. $("#results").html(s);
  24. });
  25.  
  26. });
  27. }
RAW Paste Data