Google Maps V3会从数组中绘制多个标记

时间:2013-04-18 10:28:01

标签: jquery google-maps google-maps-api-3

我试图从数组中绘制标记但是当我使用下面的代码时,会弹出一个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);
            }
        });
    });

目前我的位置会写入数组,但除了复制控制台的一部分外,我似乎无法向您显示此内容。(

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()方法似乎超过了我的每秒查询限制。

提前致谢

0 个答案:

没有答案