我试图使用Google Places API Web服务从地方详细信息请求中获取数据,例如电话号码。我无法获得类似于此guide中显示的响应数据,即使我从同一地址获取地点标识。如何使用Google Places API Web Service从地点详情请求中获取所有地点详情?
我得到的地方标识与指南中的标识不同。我的地点ID是'ChIJ8UadyjeuEmsRDt5QbiDg720',他们是'ChIJN1t_tDeuEmsRUsoyG83frY4'。如果我使用他们的地点ID,我可以获得我需要的所有数据。我可以得到的唯一数据是:address_components,adr_address,formatted_address,geometry,icon,id,name,place_id,引用,范围,类型,url和附近。如何从请求中获取电话号码等数据?
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 Maps 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();
库我使用,以获得地方ID在第一地方使用地理编码服务,所以我认为这是问题。感谢您指出地址差异 – pyromancer2