Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何使用getJSON foursquare场馆API获取街道地址?_Jquery_Json_Api_Foursquare - Fatal编程技术网

Jquery 如何使用getJSON foursquare场馆API获取街道地址?

Jquery 如何使用getJSON foursquare场馆API获取街道地址?,jquery,json,api,foursquare,Jquery,Json,Api,Foursquare,以下是场馆通常的API json响应 这就是我目前掌握的代码 $.getJSON('https://api.foursquare.com/v2/venues/search?ll=32.7153,-117.1564&limit=14&radius=1000&client_id=PKAHBB1OAX0B000CG5UUYO4BXV0LWQWKFB51EK3XVNFJ2ULS&client_secret=RDPX01C01RHCYASZIKVH5XXMPVFIPLFH

以下是场馆通常的API json响应

这就是我目前掌握的代码

$.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");

   });
$.getJSON('https://api.foursquare.com/v2/venues/search?ll=32.7153,-117.1564&极限=14&半径=1000&客户id=PKAHBB1OAX0B000CG5UUYO4BV0LWQWKFB51EK3xVNFJ2ULS&客户机密=RDPX01C01RCYASZIKVH5XXMPVFIPLFHFP1D53UR4GUWQD50&v=20120101',
功能(数据){
控制台日志(数据);
$。每个(data.response.vices,功能(i,场馆){
content=''+victions.name+'

'; $(内容)。附于(“#场馆”); });
}))


但这只是抓住了场馆的名称。如何在location部分下获取地址和Lat,Long?

地址和Lat/lon实际上在您从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");

   });
});
$.getJSON('https://api.foursquare.com/v2/venues/search?ll=32.7153,-117.1564&极限=14&半径=1000&客户id=PKAHBB1OAX0B000CG5UUYO4BV0LWQWKFB51EK3xVNFJ2ULS&客户机密=RDPX01C01RCYASZIKVH5XXMPVFIPLFHFP1D53UR4GUWQD50&v=20120101',
功能(数据){
控制台日志(数据);
$。每个(data.response.vices,功能(i,场馆){
content='Name:'+victions.Name+
'地址:'+Victories.location.Address+
“Lat/long:”+VICENCES.location.Lat+”、“+VICENCES.location.lng+”

”; $(内容)。附于(“#场馆”); }); });