Ant*_*ina 5 javascript 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);
}
Run Code Online (Sandbox Code Playgroud)
这是我的地方详细信息搜索,它获得了无效的请求状态
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);
}
);
}
Run Code Online (Sandbox Code Playgroud)
我在那里有if(状态=== google.maps.places.PlaceService.OK).所以,如果有人抓住这个问题,那就不是问题了.
任何帮助将不胜感激...我想要这个工作!