使用js和google maps api v3解决地点照片(地点库)

时间:2017-07-28 12:52:15

标签: javascript google-maps google-maps-api-3

我正在开发一个可以显示少数地方照片的网站。我得到这样的照片:

var photos = typeof place.photos !== 'undefined' ? place.photos[0].getUrl({ 'maxWidth': 100, 'maxHeight': 125 }) : '';
if (photos.length) {//...//}

不幸的是,当我想要显示他们出现的照片时,定义非常糟糕:

enter image description here

注意:我使用w3schools slideshows显示照片,并按照以下方式设置照片:

var images = document.getElementById("PhotoFond").getElementsByTagName("img");
for (i=0; i<images.length; i++;) {

    if (!photosSlide[i]) {return;}
    images[n - 1].src = photosSlide[i];

}

然而,当我去谷歌地图并找到相同的照片(link to the same photo)时,质量会更好。

enter image description here

我如何获得相同的分辨率?

1 个答案:

答案 0 :(得分:4)

docs

  

photos []:一组PlacePhoto对象。 PlacePhoto可用于使用getUrl()方法获取照片,或者您可以检查对象以获取以下值:

     

高度:图像的最大高度,以像素为单位。

     

width:图像的最大宽度,以像素为单位。

     

html_attributions:使用此地方照片显示的归因文字。

.getUrl({ 'maxWidth': 1000, 'maxHeight': 1250 }) // Just set higher resolution, no?

google-place-api-placedetails-photo-reference