javascript 如何从谷歌地点 api 获取地点照片

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17390843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 08:09:16  来源:igfitidea点击:

How to get photo of place from google places api

javascriptgoogle-places-apivargeturl

提问by Mark West

I'm beginer to js and api

我是 js 和 api 的初学者

I have an for me big problem..

我有一个大问题..

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

如何使用谷歌地点 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?

如何将此 [object Object] 更改为图像的 url?

also i try with:

我也尝试:

var photo = place.photos.geturl(); 

but also dont work...

但也不起作用...

How to solve this problem?

如何解决这个问题呢?

回答by Dr.Molle

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

place.photos是一个 Array ,您必须选择该数组的一个项目才能获取特定照片的详细信息

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

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