So I’m trying to log all the places around me, and then grab the reviews of those places with google places library.
I manage to grab all the id’s of places (around 20 of them) and when I try to grab the review, I only get reviews for 9 places and it completely ignores all the other places. Why is that?
Here’s a bit of the code:
var allplaces = [];
var placeID;
var newMap = new google.maps.places.PlacesService(map);
function displayReviews(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
var place;
for (var i = 0; i < results.length; i++) {
var place = results[i].place_id;
allplaces.push(place);
}
for (var i = 0; i < allplaces.length; i++) {
placeID = { placeId: allplaces[i] };
console.log(placeID);
newMap.getDetails(placeID, function(allplaces) {
console.log(allplaces.reviews);
});
}
}
}
So I have an array (allplaces) which stores all the places id, and I’m running a loop in which I have an object (placeID) and its property of “placeId”. After that, I’m grabbing the details from the new map that was defined outside of this function that should console log allplaces reviews, but I only get a few.
And then I get this error. It’s like the function itself doesn’t follow the order that it was written in. Am I missing something?