“OVER_QUERY_LIMIT”Google地理编码无法识别我的API密钥

时间:2017-06-29 14:45:49

标签: api google-maps google-geocoding-api

当我咨询Google地理编码API时,它会回复错误“OVER_QUERY_LIMIT”,我正在使用API​​ KEY,但google不会识别它,因为当我执行请求时,我看到了面板({{3 }}和donth有任何要求。我使用的URL的一个例子是:

 <style type="text/css">
        @media print 
        {
            .dontprint{display:none} 
        }
    </style>
    <script type="text/javascript">
        function printIframePdf(iframeId=''){
        alert(iframeId);
            window.frames[iframeId].focus();
            try {
                window.frames[iframeId].print();
            }
            catch(e){
                window.print();
                console.log(e);
            }
        }
        function printObjectPdf(iframeId='') {
           try{            
                document.getElementById('idPdf').Print();
            }
            catch(e){
                if( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ){
                    printIframePdf(iframeId);
                }else{
                    var url = document.getElementById(iframeId).src;
                    window.open(url, '_blank');
                }
            }
        }

        function idPdf_onreadystatechange() {
            if (idPdf.readyState === 4)
                setTimeout(printObjectPdf(iframeId), 1000);
        }
    </script>
    <div class="dontprint" >
        <form><input type="button" onClick="printObjectPdf('printf1')" class="btn" value="Print"/></form>
        <form><input type="button" onClick="printObjectPdf('printf2')" class="btn" value="Print"/></form>
    </div>

    <iframe id="printf1" name="printf1" src="http://localhost/PDFtest/Device-Details.pdf" frameborder="0" width="440" height="580" style="width: 440px; height: 580px;display: none;"></iframe>

    <iframe id="printf2" name="printf2" src="http://localhost/PDFtest/Prod-Support-Material.pdf" frameborder="0" width="440" height="580" style="width: 440px; height: 580px;display: none;"></iframe>

1 个答案:

答案 0 :(得分:0)

您必须对地址字符串进行URL编码,然后才能将其传递给请求,否则任何特殊符号都会破坏请求。

https://developers.google.com/maps/web-services/overview#BuildingURLs

在您的示例中,打破请求的特殊符号为#,应替换为%23。

https://maps.googleapis.com/maps/api/geocode/json?address=CALLE%2011%20%23%208%20-%2026%2C%20Cucuta%2C%20Norte%20de%20Santander%2C%20Colombia&key=YOUR_API_KEY

希望这有帮助!