Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 试图从google places API中提取数据_Javascript_Google Places Api - Fatal编程技术网

Javascript 试图从google places API中提取数据

Javascript 试图从google places API中提取数据,javascript,google-places-api,Javascript,Google Places Api,试图从GooglePlacesAPI中提取数据,但在阅读文档后无法使其工作。我肯定错过了什么,有人能帮忙吗 <script> var request = { location: new google.maps.LatLng(-33.8665433,151.1956316), radius: '500', types: ['store'] }; var service = new google.maps.pl

试图从GooglePlacesAPI中提取数据,但在阅读文档后无法使其工作。我肯定错过了什么,有人能帮忙吗

<script>

    var request = {
        location: new google.maps.LatLng(-33.8665433,151.1956316), 
        radius: '500',
        types: ['store']
    };

    var service = new google.maps.places.PlaceService(map);
    service.nearbySearch(request, callback);

    function callback(results, status) {
        for(var i = 0; i < results.length; i++){
            document.write(results[i] + '<br/>'); 
        }
    };      


    </script> 

var请求={
位置:新google.maps.LatLng(-33.8665433151.1956316),
半径:'500',
类型:['store']
};
var服务=新的google.maps.places.PlaceService(地图);
服务.nearbySearch(请求、回调);
函数回调(结果、状态){
对于(var i=0;i');
}
};      

通过将代码更改为以下内容,我消除了错误:

var请求={
位置:新google.maps.LatLng(-33.8665433151.1956316),
半径:'500',
类型:['store']
};
服务=新的google.maps.places.PlacesService(地图);
服务.nearbySearch(请求、回调);
if(status==google.maps.places.PlacesServiceStatus.OK){
函数回调(结果、状态){
对于(变量i=0;i<7;i++){
编写(结果[i]+“测试
”); } } };

但是它仍然没有返回任何数据。请找个人帮忙。谢谢

Google Maps JavaScript API v3的代码示例-将库放在文档的末尾

您可以在搜索附近看到Place Library的一个工作示例。

因此,“无法使其工作”将“未定义不是函数”视为错误。没有归还任何东西。提前谢谢!
    var request = {
        location: new google.maps.LatLng(-33.8665433,151.1956316), 
        radius: '500',
        types: ['store']
    };


    service = new google.maps.places.PlacesService(map);
    service.nearbySearch(request, callback);
     if (status == google.maps.places.PlacesServiceStatus.OK){
    function callback(results, status) {
        for(var i = 0; i < 7; i++){
            document.write(results[i] + 'test <br/>'); 
        }
        }
    };      


    </script>