Google 地图地理编码 :: 地理编码功能在 11 个请求后停止

Google Maps Geocoding :: geocode function stop after 11 requests

在下面的代码中 table locs 包括一些来自希腊不同地区的名字。对于每个区域,我调用 graphicMap 函数 通过 地理编码服务 查找纬度和经度,并在地图上创建一个标记。

但是从索引 12 开始显示错误。

查看以下结果:

错误:CHANION

好的:ANDRAVIDAS - KILLINIS

确定:VERIAS

确定:AVDIRON

好的:阿查农

好的:阿斯蒂帕莱亚斯

确定:瑞秋

好的:GALATSIOU

好的:戴尔芬

好的:天鹅绒

好的:ZAGORAS - MOURESIOU

确定:射箭

例如,如果我删除记录 ACHARNON,CHANION 的值将正常工作。

google是否对通过地理编码服务的搜索设置了限制?

这是我没买API KEY吗?

提前致谢!

geocodeLatLong( JXMapContent , map , mapSet , graphic , graph , pins ){
    /**
    **** @procedure
    **** Split and create table with the regions
    **** Iterate table and find coordinates for each region
    **/     
    var locs = JXMapContent.split( "," ) , u , length_table = locs.length;
    for( u = 0; u < length_table; u++ )
    {
        graph( locs[ u ] , map , graphic , pins );
    }

}

graphicMap( _location , map , graphic , pins ){
    var geocoderRequest = {
        address: _location
    };
    graphic.geocode( geocoderRequest, function(results, status) {
        if (status === google.maps.GeocoderStatus.OK){

            var marker = new google.maps.Marker({
                map:map,
                position : results[0].geometry.location,
                icon:"images/marker.png",
                animation:google.maps.Animation.DROP
            });

            pins.push( marker );
            marker.addListener('click', function() {
                for (var i = 0; i < pins.length; i++) {
                    pins[i].setAnimation(null);
                }
                if( this.getAnimation() !== null) {
                    this.setAnimation(null);
                } else {
                    this.setAnimation(google.maps.Animation.BOUNCE);
                }
            });
            console.log( "OK : " + _location );
        }else{
            console.log( "Error : " + _location );
        }
    });
}

虽然您可以针对 google 地图的地理编码服务进行的 API 调用肯定会有限制,但也许您可以查看返回的错误代码以便了解发生了什么。如果您能了解更多详细信息 "google giving you an error" 就好了。

从他们的文档中,您可以在此处找到错误代码 https://developers.google.com/maps/documentation/javascript/geocoding?hl=es#GeocodingStatusCodes

如果您要超过配额,您会看到 "OVER_QUERY_LIMIT" 例如...

如果一个错误只是意味着那个城市没有结果,也许它只是给你一个 "ZERO_RESULTS" 而你没有正确解析其余部分并且你的 JS 失败