2013-02-22 154 views
0

繼承人什麼平常API JSON響應看起來像場館 https://developer.foursquare.com/docs/explore#req=venues/search%3FproviderId%3Dnymag%26linkedId%3D59455我如何使用getJSON foursquare場地API獲取街道地址?

,這是我的代碼至今

$.getJSON('https://api.foursquare.com/v2/venues/search?ll=32.7153,-117.1564&limit=14&radius=1000&client_id=PKAHBB1OAX0B000CG5UUYO4BXV0LWQWKFB51EK3XVNFJ2ULS&client_secret=RDPX01C01RHCYASZIKVH5XXMPVFIPLFHFP1D53UR4GUWQD50&v=20120101', 
function(data) { 
console.log(data); 
    $.each(data.response.venues, function(i,venues){ 
     content = '<p>' + venues.name + '</p>'; 
     $(content).appendTo("#venues"); 

    }); 

});

但那只是抓住場地名稱。我如何在地點部分下抓取地址和Lat,Long?

回答

0

地址和緯度/經度實際上暴露在您從Foursquare收到的回覆中。嘗試:

$.getJSON('https://api.foursquare.com/v2/venues/search?ll=32.7153,-117.1564&limit=14&radius=1000&client_id=PKAHBB1OAX0B000CG5UUYO4BXV0LWQWKFB51EK3XVNFJ2ULS&client_secret=RDPX01C01RHCYASZIKVH5XXMPVFIPLFHFP1D53UR4GUWQD50&v=20120101', 
function(data) { 
console.log(data); 
    $.each(data.response.venues, function(i,venues){ 
     content = '<p>Name: ' + venues.name + 
      ' Address: ' + venues.location.address + 
      ' Lat/long: ' + venues.location.lat + ', ' + venues.location.lng + '</p>'; 
     $(content).appendTo("#venues"); 

    }); 
}); 
+0

工作!謝謝你的幫助octopi – 2013-02-22 23:44:31

相關問題