未定义的对象从JavaScript与json [英] Undefined objects from json with javascript

查看:94
本文介绍了未定义的对象从JavaScript与json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我有一个创建map和sibar的链接代码,但是在infowindow中一切正常,并且在侧边栏中我只能获取未定义的文本:

http://jsbin.com/EVEWOta/23 (只需点击提交)



那究竟是什么问题?



CODE:

  var side_bar_html =< a href ='javascript:google.maps.event.trigger(gmarkers [+ parseInt(gmarkers.length-1)+],\mouseover \);'> ; + place.name + < / A><峰; br>中; 
document.getElementById('side_bar')。innerHTML + = side_bar_html;


解决方案

您正在使用 RadarSearch



从文档:


雷达搜索()返回的PlaceResult对象将仅包含geometry.location和引用属性。


没有.name属性


Here I have a code for creating map and sibar with links, but in infowindow all is ok, and in sidebar I only get undefined text:

http://jsbin.com/EVEWOta/23 (just click submit)

So what is exactly the problem?

CODE:

 var side_bar_html = "<a href='javascript:google.maps.event.trigger(gmarkers["+parseInt(gmarkers.length-1)+"],\"mouseover\");'>"+place.name+"</a><br>";
    document.getElementById('side_bar').innerHTML += side_bar_html;
}

解决方案

You are using RadarSearch.

From the documentation:

PlaceResult objects returned by radarSearch() will only include the geometry.location and reference properties.

There is no .name property

这篇关于未定义的对象从JavaScript与json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆