I’m having some problems with places api. I need to return the reviews from nearby places. I’ve read the places API, but nowhere can I find the ‘reviews’ parameter. When I try to access it with javascript, for example
console.log(place.reviews);
It returns undefined. Am I calling it wrong? And here’s a pic when I just console log (places):
There is no “reviews”.
The following code marks all the nearby places on the map, and prints the names and ratings in an ul.
function createMarker(place) {
var placeLoc = place.geometry.location;
var listItem = document.createElement('li');
var star = document.createElement('i');
var value = document.createElement('p');
value.className = 'float-right mr-2';
value.innerText = place.rating;
star.className = 'fas fa-star float-right';
listItem.className = 'list-group-item';
listItem.innerText = place.name + " ";
for(var i = 0; i < place.rating; i++) {
listItem.appendChild(star)
}
listItem.appendChild(value);
restUl.appendChild(listItem);
console.log(place.reviews)
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(place.name);
infowindow.open(map, this);
});
}
And as you can see, I’m trying to console log the reviews (just for now) but it doesn’t work. Everything else works just fine.