0

我正在尝试从数组中绘制标记,但是当我使用下面的代码时,它会弹出一个OVER_QUERY_LIMIT

$.each(obj , function(index, value){
        geocoder = new google.maps.Geocoder();
        console.log(value);
        var replaced = value.toString().replace(/\[.*\]/g,'');
        geocoder.geocode( { 'address': replaced}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                });
            } else {
                alert('Geocode was not successful for the following reason: ' + status);
            }
        });
    });

目前我的位置写入一个数组,但除了复制我的一部分 console.log() 之外,我似乎无法向你展示这个

Object { Lagos=[2], Almaty=[2], Banten=[2], more...}

如果我将数组转换为 json 以向您展示其中的所有内容,则显示如下

{"Lagos":[6.443663,3.419248],"Almaty":[43.243819,76.947697],"Banten":[43.257846,76.946418],"Kuala":[3.15021,101.707703],"Dubai":[24.9952447639,55.0559356887],"Sharjah":[43.25819,76.946332],"Esbjerg":[55.505168,8.456096],"Brighouse":[53.6986,-1.76824],"Burnley":[53.801334,-2.213863],"Ipswich":[52.080412,1.118962],"Daventry":[52.246678,-1.15401],"Yarmouth":[52.595971,1.728609],"Southampton":[50.93347,-1.505792],"Cork":[51.807925,-8.370402],"Gerenzano":[45.63942,8.998989],"Stavanger":[58.99573462,5.6308005317],"Sandnessjoen":[66.022204,12.631874],"Glenugie":[57.486747,-1.800621],"Wellbank":[57.484958,-1.813535],"Cowdenbeath":[56.09946,-3.35909],"Brisbane":[-27.46845,153.022642],"Perth":[-31.955876,115.863018],"Johns":[47.528329,-52.855225],"Halifax":[44.644811,-63.569984],"Edmonton":[53.50247,-113.425276],"Kennesaw":[34.008442,-84.583408],"Houston":[29.838801,-95.501597],"Sanford":[35.443243,-79.177523],"Cunupia":[10.571607,-61.398527],"Maracaibo":[10.67676,-71.617362]}

我的问题是如何将上述纬度和经度绘制成地图上的标记?因为当前的$.each()方法似乎超过了我每秒的查询限制。

提前致谢

4

0 回答 0