【问题标题】:Google Maps Geocoding :: geocode function stop after 11 requests [duplicate]Google Maps Geocoding :: geocode功能在11个请求后停止[重复]
【发布时间】:2020-09-13 08:38:03
【问题描述】:

在下表的代码中,locs 包含了来自希腊不同地区的一些名称。对于每个区域,我调用 graphicMap 函数 来通过 Geocoding Service 查找纬度和经度并在地图上创建标记。

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

查看以下结果:

错误:ΧΑΝΙΩΝ

OK : ΑΝΔΡΑΒΙΔΑΣ - ΚΥΛΛΗΝΗΣ

好的:ΒΕΡΟΙΑΣ

好的:AΒΔΗΡΩΝ

好的:ΑΧΑΡΝΩΝ

好的:ΑΣΤΥΠΑΛΑΙΑΣ

好的:ΡΕΘΥΜΝΗΣ

好的:ΓΑΛΑΤΣΙΟΥ

好的:ΔΕΛΦΩΝ

好的:ΒΕΛΒΕΝΤΟΥ

好的:ZΑΓΟΡΑΣ - ΜΟΥΡΕΣΙΟΥ

好的:ΒΕΛΟΥ ΒΟΧΑΣ

如果我删除例如记录 ΑΧΑΡΝΩΝ,ΧΑΝΙΩΝ 的值正常工作。

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

这是因为我没有购买 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 );
        }
    });
}

【问题讨论】:

标签: javascript google-maps geocoding


【解决方案1】:

虽然您可以针对谷歌地图的地理编码服务进行的 API 调用肯定会受到限制,但您可能可以查看返回的错误代码以了解发生了什么。你所理解的更多细节是“谷歌给你一个错误”会很棒。

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

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

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

【讨论】:

  • 谢谢亚历杭德罗!
  • 错误是 OVER_QUERY_LIMIT。
  • 快乐是我的 :)
  • 完成! @Alejandro Vales
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多