How to get photo of place from google places api

11,295

place.photos is an Array , you must select an item of the array to get details for a particular photo

https://developers.google.com/maps/documentation/javascript/places#places_photos

Share:
11,295
Mark West
Author by

Mark West

Updated on June 15, 2022

Comments

  • Mark West
    Mark West almost 2 years

    I'm beginer to js and api

    I have an for me big problem..

    How to get photo for some places with google places api.

    I try with this:

    function setLink(i) {
                var photo = place.photos;
                var sideClick = jQuery("<a class=side_click href='#'></a>");
                 $(sideClick).html(place.name+photo);
                 $("#side_bar").append(sideClick).append("<br>");
                 $(sideClick).on("click", function() {
                   markers[i].modalWindow_.getDetails(markers[i].place_);
                 });
              }
    

    and I get only something like this:

    Hotel Name [object Object]
    

    How to change this [object Object] into url of image?

    also i try with:

    var photo = place.photos.geturl(); 
    

    but also dont work...

    How to solve this problem?