如何使用 Google Places API Web 服务从地点详细信息请求中获取所有地点详细信息?

How to get all place details from a Place Details Request using Google Places API Web Service?

我正在尝试使用 Google Places API Web 服务从地点详细信息请求中获取数据,例如 phone 数字。我无法获得类似于此 guide 中显示的数据的响应数据,即使我从同一地址获取地点 ID。

我得到的地点编号与指南中的不同。我的地点 ID 是 'ChIJ8UadyjeuEmsRDt5QbiDg720',他们的是 'ChIJN1t_tDeuEmsRUsoyG83frY4'。如果我使用他们的地点 ID,我会得到我需要的所有数据。

我唯一能得到的数据是:address_components、adr_address、formatted_address、geometry、icon、id、name、place_id、reference、scope、types , url, 和附近。如何从请求中获取 phone 数字之类的数据?

var placesRequest = $http({
  method: "post",
  url: "https://maps.googleapis.com/maps/api/place/details/json?placeid=" + <my place id>+"&key=<my key>"
});

placesRequest.success(function (data) {
  console.log("data", data);
});

使用此代码的 Google 地图 JavaScript API 也有同样的问题。

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
      center: {lat: -33.866, lng: 151.196},
      zoom: 15
  });

  google.maps.InfoWindow();
  var service = new google.maps.places.PlacesService(map);

  service.getDetails({
     placeId: $scope.newUserData.address.place_id
  }, function(place, status) {
     if (status === google.maps.places.PlacesServiceStatus.OK) {
       if(place) {
         console.log("place", place);

        }
     }
  });
}
initMap();

Google 地点 API 中缺少 phone 号码,因为 Google 地图没有该特定地点的 phone 号码。如果您在 Google 地图上请求具有 phone 编号的地点的详细信息,它将被返回。

仔细看看 ChIJ8UadyjeuEmsRDt5QbiDg720。这是一栋名为 "Workplace 6" 的办公楼 — 请注意,详细信息显示它的类型为 premise。如果您在 url 字段 (https://maps.google.com/?q=Workplace+6&ftid=0x6b12ae37ca9d46f1:0x6defe0206e50de0e) 中访问 Google 地图 URL,您会发现那里也没有列出 phone 号码。

另一个地点 ID ChIJN1t_tDeuEmsRUsoyG83frY4 用于位于该建筑物内的一家企业 (Google)。如果比较 address_componentsformatted_address,您会发现它们的地址并不完全相同(Google 的地址是该建筑物的 5 楼)。

一般来说,一个地方的任何字段都可能不存在。如果 Google 地图不知道它,或者它根本不适用(例如,您在法国找不到 opening_hours),就会发生这种情况。正如 Place Details Results 的文档所说:

Each result may contain the following fields:

[强调我的。]