Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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
Javascript 从googlemap解析JSON_Javascript_Jquery_Json - Fatal编程技术网

Javascript 从googlemap解析JSON

Javascript 从googlemap解析JSON,javascript,jquery,json,Javascript,Jquery,Json,我想显示此json中的位置详细信息: 我有问题解析它,我想得到“网站”,“名称”和“评级”。 这是指向json的链接: { “html_属性”:[ “ródło wpisów:” ], “结果”:{ “地址组件”:[ { “long_name”:“10”, “短名称”:“10”, “类型”:[ “街道号码” ] }, { “long_name”:“Darling Drive”, “短名称”:“Darling Drive”, “类型”:[ “路线” ] }, { “long_名称”:“悉尼达令港”

我想显示此json中的位置详细信息: 我有问题解析它,我想得到“网站”,“名称”和“评级”。 这是指向json的链接:

{
“html_属性”:[
“ródło wpisów:”
],
“结果”:{
“地址组件”:[
{
“long_name”:“10”,
“短名称”:“10”,
“类型”:[
“街道号码”
]
},
{
“long_name”:“Darling Drive”,
“短名称”:“Darling Drive”,
“类型”:[
“路线”
]
},
{
“long_名称”:“悉尼达令港”,
“短名称”:“悉尼达令港”,
“类型”:[
“地点”,
“政治”
]
},
{
“long_名称”:“新南威尔士州”,
“短名称”:“新南威尔士州”,
“类型”:[
“行政区一级”,
“政治”
]
},
{
“龙_名称”:“AU”,
“短名称”:“AU”,
“类型”:[
“国家”,
“政治”
]
},
{
“long_name”:“2000”,
“短名称”:“2000”,
“类型”:[
“邮政编码”
]
}
],
“地址”:“澳大利亚新南威尔士州悉尼市达令港达令大道10号海港中心”,
“格式化电话号码”:(02)9211 8900,
“几何学”:{
“地点”:{
“lat”:-33.871983,
“液化天然气”:151.199086
}
},
“图标”:”http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
“id”:“677679492a58049a7eae079e0890897eb953d79b”,
“国际电话号码”:“+61 2 9211 8900”,
“名称”:“扎夫兰餐厅-烧烤和烧烤,达令港”,
“评级”:3.9,
“参考文件”:“CPQBjaaaarbNVPI6EGL3AURXJWEMZ9VA2GFABYRV-0GDQCOZ2QNYFMJIWEX1MLV2UCOFWPXKHPWQNWSKRRD58LGD7EGSUGOOWPDMD2V1XMT1YTLH0NF0YHXPFSIK62N6L2L6U6H6EKJDQVKKLERFLHL-Ezw(L4SRZ80XUFZWZWZWWWWWWWWWWWWWWWN2BDHHPGI4NWXIQ8W5G1VXS-ZYB8H6LK8Kv8F8K8K8Kv8F8K8Kv8Kv8L8K8Kv8Kv8”,
“类型”:[
“餐厅”,
“食物”,
“设立”
],
“url”:”http://maps.google.com/maps/place?cid=14075582311174685259",
“附近地区”:“悉尼达令港达令大道10号海港中心”,
“网站”:http://www.zaaffran.com/"
},
“状态”:“确定”
}

我尝试使用此功能:

$(document).ready(function() {

   $.getJSON('GOOGLE URL HERE', function(data) {
     $('#dictionary').empty();
      $.each(data, function(entryIndex, entry) {
         var html = '<div class="entry">';
         html += '<h3 class="term">' + entry['name'] + '</h3>';
         html += '<div class="part">' + entry['website'] + '</div>';
         html += '<div class="definition">';
         html += entry['rating'];
         html += '</div>';
         html += '</div>';
         $('#dictionary').append(html);
      });
   });
   return false;
$(文档).ready(函数(){
$.getJSON('GOOGLE URL HERE',函数(数据){
$(“#字典”).empty();
$.each(数据、函数(entryIndex、条目){
var html='';
html+=''+条目['name']+'';
html+=''+条目['website']+'';
html+='';
html+=条目[‘评级’];
html+='';
html+='';
$('#dictionary').append(html);
});
});
返回false;
}))

这对我不起作用。 请帮帮我,非常感谢。 Michal

更换:

 $.each(data, function(entryIndex, entry) {
     var html = '<div class="entry">';
     html += '<h3 class="term">' + entry['name'] + '</h3>';
     html += '<div class="part">' + entry['website'] + '</div>';
     html += '<div class="definition">';
     html += entry['rating'];
     html += '</div>';
     html += '</div>';
     $('#dictionary').append(html);
  });
$。每个(数据、函数(entryIndex、条目){
var html='';
html+=''+条目['name']+'';
html+=''+条目['website']+'';
html+='';
html+=条目[‘评级’];
html+='';
html+='';
$('#dictionary').append(html);
});
与:

var html='';
html+=''+数据。结果['name']+'';
html+=''+数据。结果['website']+'';
html+='';
html+=条目[‘评级’];
html+='';
html+='';
$('#dictionary').append(html);

不需要
每个
。使用
data.result.name
直接访问数据,因为
data
result

是一个单独的对象-这是我网站的完整代码,它仍然不起作用。它应该是data.result.name,而不是data.result['name')。好的,谢谢我更改它:。没有错误,可能是google apikey的问题吧?它仍然不起作用(好的,它可以工作,但只有当我想从文件中读取json时…从url读取json不起作用…有什么想法吗?谢谢帮助!对不起,但我的英语不流利,如何从url文件中读取json,这对我来说非常重要…我认为此链接是正确的:
 $.each(data, function(entryIndex, entry) {
     var html = '<div class="entry">';
     html += '<h3 class="term">' + entry['name'] + '</h3>';
     html += '<div class="part">' + entry['website'] + '</div>';
     html += '<div class="definition">';
     html += entry['rating'];
     html += '</div>';
     html += '</div>';
     $('#dictionary').append(html);
  });
     var html = '<div class="entry">';
     html += '<h3 class="term">' + data.result['name'] + '</h3>';
     html += '<div class="part">' + data.result['website'] + '</div>';
     html += '<div class="definition">';
     html += entry['rating'];
     html += '</div>';
     html += '</div>';
     $('#dictionary').append(html);