gpt4 book ai didi

javascript - Google Places API 获取详细信息 - 无效请求

转载 作者:数据小太阳 更新时间:2023-10-29 05:46:24 24 4
gpt4 key购买 nike

所以我正在尝试根据 google places 文本搜索获取详细信息。我的文本搜索工作正常,但为了获取详细信息,我不断收到“无效请求”。

我遵循了文档中的示例以及其他人的示例,但无济于事,我失败了....

这是我的文本搜索,它正在运行。

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);
}
);
}

我在那里有 if(status === google.maps.places.PlaceService.OK)。所以这不是问题,以防有人发现。

如有任何帮助,我们将不胜感激...我希望它能正常工作!

最佳答案

8deae188679ff8b9344085de5360a769879240f9 不是地点 ID。我怀疑您使用的 PlaceResult.id 不适用于详细信息请求并且是 deprecated .

改为使用 PlaceResult.place_id。参见 the documentation有关详细信息和示例。

关于javascript - Google Places API 获取详细信息 - 无效请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36710345/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com