特定地点id的照片

Photos of particular place id

如何获取特定 "place_id" 的所有图片?

当我在特定位置检索 "places" 的列表时,我只能访问一个特定图像 "photo_reference"。

我想通过它的"places_id"(更具体的搜索)显示地点的详细信息,但是API功能的结果没有出现相关图片。如果您正在查看 google 放置 "id" 具体的地方,则会出现更多图像。我怎样才能恢复它们?

谢谢

当地点 API 没有 return 任何照片时,您可以使用街景图像 API。您可以使用从街景请求中的地点响应收到的坐标 API 到 link 类似这样的内容:

https://maps.googleapis.com/maps/api/streetview?size=600x300&location=46.414382,10.013988&key=YOUR_API_KEY

您可能需要在 google 开发人员控制台中启用街景视图 api 以及您的地点 api。

街景参考: https://developers.google.com/maps/documentation/streetview/?hl=en

假设您有一个 ID 为 attributions 的元素和一个 ID 为 image 的元素,您可以使用 JavaScript API 执行以下操作。代码笔:http://codepen.io/anon/pen/adooRp

  var attributions = document.getElementById("attributions");   
  var service = new google.maps.places.PlacesService(attributions);

  var request = {
      placeId: 'ChIJ10KlwAdzXg0RsH56kZsfcHs'   
  };

  service.getDetails(request, function(place, status) {
      if (status == google.maps.places.PlacesServiceStatus.OK) {
          var lat = place.geometry.location.lat();
          var lng = place.geometry.location.lng();

          var src = "https://maps.googleapis.com/maps/api/streetview?size=600x300&location="
+ lat + "," + lng + "&key=YOUR_API_KEY_HERE";

          document.getElementById("image").src = src;

      }   
  });