繁体   English   中英

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

[英]Google Places API get details - Invalid Request

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

我已经按照文档中的例子,以及其他人的例子,但无济于事,我失败了....

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

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(状态=== google.maps.places.PlaceService.OK)。 所以,如果有人抓住这个问题,那就不是问题了。

任何帮助将不胜感激...我希望这个工作!

8deae188679ff8b9344085de5360a769879240f9不是地方ID。 我怀疑你正在使用PlaceResult.id ,它不适用于详细信息请求并且已被弃用

而是使用PlaceResult.place_id 有关详细信息和示例,请参阅文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM