I know that the getUrl function of photo works as it returns a valid url.
Yes, IF there is a photo associated with the place! No photo for a place = no photo
array in the results[i]
object. And then your code breaks. You must in each iteration check if the photo
array is present before using it :
place = new Object ({
name: results[i].name,
photo: typeof results[i].photos !== 'undefined'
? results[i].photos[0].getUrl({'maxWidth': 100, 'maxHeight': 100})
: '' //alternative a "nophoto.jpg"
loc: results[i].geometry.location,
rating: results[i].rating,
});
Here a fiddle based on your code from above -> http://jsfiddle.net/dX9Gu/