0

I'm trying to plot markers from an array but when I use the code below it pops up with an 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);
            }
        });
    });

Currently my locations write to an array but I can't seem to show this to you besides copying a part of my console.log()

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

If I convert my array to json to show you all what is in it, it shows as below

{"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]}

My question is how do I plot the above latitudes and longitudes into markers on my map? as the current $.each() method seems to go over my query limit per second.

Thanks in advance

ngplayground
  • 20,365
  • 36
  • 94
  • 173
  • possible duplicate of [Google Maps API OVER QUERY LIMIT per second limit](http://stackoverflow.com/questions/14014074/google-maps-api-over-query-limit-per-second-limit) or search for one of the [many other duplicates](http://stackoverflow.com/search?q=%5Bgoogle-maps-api-3%5D+geocoder+OVER_QUERY_LIMIT). – geocodezip Apr 18 '13 at 10:38
  • Do you already have the latitude and longitude in your array, prior to calling the geocoder.geocode() function? – duncan Apr 18 '13 at 10:41

0 Answers0