Google maps api 3 谷歌发布JSAPI展示评论

Google maps api 3 谷歌发布JSAPI展示评论,google-maps-api-3,google-places-api,Google Maps Api 3,Google Places Api,jsapi,而不是web服务: 我无法显示位置详细信息响应中包含的0-5条评论: 到目前为止,我已经能够显示这些项目: details.name 详情.评级 详细信息。现在打开 details.u地址 详细信息.类型 详细信息。格式化的电话号码 但当我尝试显示详细信息时,它只显示: [对象对象],[对象对象],[对象对象],[对象对象对象],[对象对象] 有人成功地展示了评论吗 函数createMarker(位置){ var image='img/marker.png'; var plac

jsapi,而不是web服务:

我无法显示位置详细信息响应中包含的0-5条评论:

到目前为止,我已经能够显示这些项目:

  • details.name
  • 详情.评级
  • 详细信息。现在打开
  • details.u地址
  • 详细信息.类型
  • 详细信息。格式化的电话号码
但当我尝试显示详细信息时,它只显示:

[对象对象],[对象对象],[对象对象],[对象对象对象],[对象对象]

有人成功地展示了评论吗

函数createMarker(位置){
var image='img/marker.png';
var placeLoc=place.geometry.location;
var marker=new google.maps.marker({
地图:地图,
图标:图像,
位置:place.geometry.location
});
var请求={reference:place.reference};
service.getDetails(请求、函数(详细信息、状态){
google.maps.event.addListener(标记'click',函数(){
if(status==google.maps.places.PlacesServiceStatus.OK){
//将导航链接中的空格替换为+符号
var navLink=details.formatted\u地址;
navLink=navLink.replace(/\s/g,“+”);
$('.navLink').html(navLink);
//将评级条宽度与评级编号匹配
var ratingWidth=(详细信息.额定值*20)+“px”;
$('.rating bar>span').css('width',“'+'ratingWidth+”);
var contentStr=''+details.name+'
    ; 如果(!!details.rating)contentStr+='
  • 评级:'+details.rating+'
  • '; if(!!details.open_now)contentStr+='
  • '+details.open_now+'
  • '; contentStr+='
  • '+详细信息。格式化的地址+'
  • '; contentStr+='
  • '+详细信息.类型+'
  • '; //检查平台是否发送适当的应用程序链接 if((navigator.platform.indexOf(“iPhone”)!=-1)){ contentStr+='
  • ; }否则{ contentStr+='
  • ; } 如果(!!details.formatted_phone_number)contentStr+='
  • '; 如果(!!details.reviews)contentStr+='
  • '+details.reviews+'
  • '; contentStr+='
'; infowindow.setContent(contentStr); 信息窗口。打开(地图、标记); }否则{ var contentStr=“无结果,状态=“+status+”; infowindow.setContent(contentStr); 信息窗口。打开(地图、标记); } }); }); }
详细信息。reviews
不返回字符串(您在输出中得到的是此数组的字符串表示形式),它是一个最多包含5个review对象的数组。您必须迭代此数组的项,并自行准备输出

准备评审的示例函数:

(function (rs /*reviews-array*/ , fx /*review-parser*/ ) {
        var list = document.createElement('ul');
        rs.forEach(function (r) {
            list.appendChild(fx(r));
        });

        return '<ul>' + list.innerHTML + '</ul>';
        //remove the previous line when you want to return a DOMNode
        return list;
    }
    (details.reviews,
        function (r /*single review*/ ) {
            console.log(r.aspects)
            var item = document.createElement('li'),
                review = item.appendChild(document.createElement('ul'))
            props = {
                author_name: 'author',
                rating: 'rating',
                text: 'text'
            };
            item.appendChild(document.createElement('h6'));
            item.lastChild.appendChild(document.createElement('a'));
            item.lastChild.lastChild
               .appendChild(document.createTextNode(r.author_name));
            if (r.author_url) {
                item.lastChild.lastChild.setAttribute('href', r.author_url);
            }
            item.lastChild.appendChild(document.createTextNode('(' + r.rating +
                ')'));
            if (r.aspects && r.aspects.length) {
                item.appendChild(document.createElement('ul'));
                r.aspects.forEach(function (a) {
                    item.lastChild.appendChild(document.createElement(
                        'li'));
                    item.lastChild.lastChild
                        .appendChild(document.createTextNode(a.type +
                            ':' + a.rating))
                });
            }
            item.appendChild(document.createElement('p'));
            item.lastChild.appendChild(document.createTextNode(r.text));
            return item;
        }
    ))

请提供一个演示该问题的示例。这非常完美。非常感谢。我知道我丢了一些钥匙。