Javascript 使用radarSearch方法和getDetails方法从Google地图检索更多数据

Javascript 使用radarSearch方法和getDetails方法从Google地图检索更多数据,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我可以知道在使用radarSearch方法(可以检索200个结果)和getDetails方法时,如何从Google地图中获取10个以上的数据结果吗?我希望所有标记信息都列在地图下方的空白处。然而,我只得到了10个。我可以知道问题吗?10个结果保持不变,在浏览器刷新几次时,可能只更改其中1个 下面是我用来从GoogleMap检索信息并创建标记的代码。我使用雷达搜索方法进行搜索 function callback(results, status) { if (status !== go

我可以知道在使用radarSearch方法(可以检索200个结果)和getDetails方法时,如何从Google地图中获取10个以上的数据结果吗?我希望所有标记信息都列在地图下方的空白处。然而,我只得到了10个。我可以知道问题吗?10个结果保持不变,在浏览器刷新几次时,可能只更改其中1个

下面是我用来从GoogleMap检索信息并创建标记的代码。我使用雷达搜索方法进行搜索

   function callback(results, status) {
    if (status !== google.maps.places.PlacesServiceStatus.OK) {
      console.error(status);
      return;
    }
    for (var i = 0, result; result = results[i]; i++) {
      addMarker(result);
    }
  }

  function addMarker(place) {
    var placesList = document.getElementById('test');
    var marker = new google.maps.Marker({
      map: map,
      position: place.geometry.location,
      icon: {
        url: 'http://maps.gstatic.com/mapfiles/circle.png',
        anchor: new google.maps.Point(10, 10),
        scaledSize: new google.maps.Size(10, 17)
      }
    });


      service.getDetails(place, function(result, status) {
        if (status !== google.maps.places.PlacesServiceStatus.OK) {
          console.error(status);
          return;
        }

        iname = result.name;
        iLatitude = [result.geometry.location.lat()];
        iLongitude = [result.geometry.location.lng()];
        iAddress = [result.formatted_address];

      placesList.innerHTML += '<li>' + iname +'&nbsp;&nbsp;&nbsp;&nbsp;'+ iAddress + '</li>';
      });
  }
函数回调(结果、状态){
if(status!==google.maps.places.PlacesServiceStatus.OK){
控制台错误(状态);
返回;
}
for(变量i=0,结果;结果=结果[i];i++){
添加标记(结果);
}
}
功能添加标记(位置){
var placesList=document.getElementById('test');
var marker=new google.maps.marker({
地图:地图,
位置:place.geometry.location,
图标:{
网址:'http://maps.gstatic.com/mapfiles/circle.png',
主播:新谷歌地图点(10,10),
scaledSize:新的google.maps.Size(10,17)
}
});
service.getDetails(位置、功能(结果、状态){
if(status!==google.maps.places.PlacesServiceStatus.OK){
控制台错误(状态);
返回;
}
iname=result.name;
iLatitude=[result.geometry.location.lat()];
iLongitude=[result.geometry.location.lng()];
iAddress=[result.formatted_address];
placesList.innerHTML+='
  • '+iname+'+iAddress+'
  • '; }); }
    结果的屏幕截图。

    实际上问题是由于超限问题,当发送请求的时间延迟时可以绕过,可以实现setTimeout方法来避免超限问题

    替换为下面的代码。可以检索地图上的所有标记数据(目前我在谷歌地图上有148个餐厅标记)

    service.getDetails(地点、功能(结果、状态){
    if(status==google.maps.places.PlacesServiceStatus.OK){
    iname=result.name;
    iLatitude=[result.geometry.location.lat()];
    iLongitude=[result.geometry.location.lng()];
    iAddress=[result.formatted_address];
    placesList.innerHTML+='
  • '+iname+'+iAddress+'
  • '; } else if(status==google.maps.GeocoderStatus.OVER\u QUERY\u LIMIT){ setTimeout(函数(){ 添加标记(位置); }, 200); } });
    place服务有配额和费率限制(检查返回的状态,您正在记录)@geocodezip,先生,这是因为getDetails获得配额吗?我从文档中了解到的是搜索方法get quota,但是没有关于getDetails的配额的明确声明。先生,请您详细解释一下。谢谢。谷歌的所有服务都有配额和费率限制,
    getDetails
    也一样(你应该在第10项后记录状态
    OVER\u QUERY\u limit
    )@geocodezip,先生,我能用你在论坛上提出的解决方案来解决OVER\u QUERY\u limit问题吗?
       service.getDetails(place, function(result, status) {
            if (status === google.maps.places.PlacesServiceStatus.OK) {
    
            iname = result.name;
            iLatitude = [result.geometry.location.lat()];
            iLongitude = [result.geometry.location.lng()];
            iAddress = [result.formatted_address];
    
            placesList.innerHTML += '<li>' + iname + ''+ iAddress + '</li>';
            }
    
            else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
            setTimeout(function() {
                addMarker(place);
            }, 200);
        }
          });