Settimeout to avoid over_query-limit

后端 未结 2 594
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 14:07

i am trying to retrieve addresses using the googlemaps geocoder..but iam getting only few addresses ..as i see my javascript is failing to retrieve after 10 addresses..below

相关标签:
2条回答
  • 2020-12-11 14:37

    The solution is use setTimeout to prevent OVER_QUERY_LIMIT:

    function createMarker(place) {
        //var placeLoc = place.geometry.location;
        //var marker = new google.maps.Marker({map: map,zIndex: 100,position: place.geometry.location});
    
        var request = {
            reference : place.reference,
        };
    
        service = new google.maps.places.PlacesService(map);
    
        service.getDetails(request, function(details, status) {
            if (status === google.maps.places.PlacesServiceStatus.OK) {
                $('#placedata').append('<tr><td><a href='+details.url+'>' + details.name + '</a></td></tr>');
            } else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
                setTimeout(function() {
                    createMarker(place);
                }, 200);
            }
        });
    }
    
    0 讨论(0)
  • 2020-12-11 14:38

    I have the solution for this.

    try this

    if(pagination.hasNextPage){
    pagination.nextPage();
    }
    
    if(pagination.b == null){
    createMarker(place);
    }
    

    //No need for setTimeout. try this. it will be helpful to you.

    0 讨论(0)
提交回复
热议问题