1
因此,我试图根据Google地方文本搜索来获取详细信息。我的文本搜索工作正常,但为了获取详细信息,我不断收到“无效的请求”。Google Places API获取详细信息 - 无效请求
我已经按照从文档,以及其他人,但没有用实例的例子,我已经失败....
这是我的文本搜索,这是工作。
var lat = '43.09182244507046'
var lng = '-89.48985488807972'
var places;
function initialize() {
var location = new google.maps.LatLng(lat,lng);
var map = new google.maps.Map(document.getElementById('map'),{
center: location,
zoom: 15
});
var request = {
location: location,
radius: '50000',
query: 'food'
};
var callback = function (results, status) {
places = results;
console.log(status);
console.log(places);
}
var service = new google.maps.places.PlacesService(map);
service.textSearch(request, callback);
}
这是我的地方详细信息搜索这是越来越无效请求状态
var place_details;
function getDetails() {
var location = new google.maps.LatLng(lat,lng);
var map = new google.maps.Map(document.getElementById('map'),{
center: location,
zoom: 15
});
var callback = function (results, status) {
place_details = results;
};
var service = new google.maps.places.PlacesService(map);
service.getDetails({
placeId: "8deae188679ff8b9344085de5360a769879240f9"}, function(place, status){
place_details = place;
console.log(place_details);
console.log(status);
}
);
}
我有,如果(状态=== google.maps.places.PlaceService.OK)在那里。所以这不是问题,如果有人抓住了这一点。
任何帮助,将不胜感激...我想这个工作!
那真是个愚蠢的错误。它使我搜索论坛几个小时。非常感谢。 – Talha
很高兴我能帮忙,@Talha。 – spiv
我尝试使用'PlaceResult.placeId',但这也没有工作(我得到了'undefined'),使用Places API V3它似乎被命名为'PlaceResult.place_id'。 – SidOfc