0

In the code below table locs includes some names from different regions in Greece. For each region I call graphicMap function to find latitude and longitude through Geocoding Service and create a marker on map.

But from index 12 and after it show error.

See the results below:

Error : ΧΑΝΙΩΝ

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

OK : ΒΕΡΟΙΑΣ

OK : ΑΒΔΗΡΩΝ

OK : ΑΧΑΡΝΩΝ

OK : ΑΣΤΥΠΑΛΑΙΑΣ

OK : ΡΕΘΥΜΝΗΣ

OK : ΓΑΛΑΤΣΙΟΥ

OK : ΔΕΛΦΩΝ

OK : ΒΕΛΒΕΝΤΟΥ

OK : ΖΑΓΟΡΑΣ - ΜΟΥΡΕΣΙΟΥ

OK : ΒΕΛΟΥ ΒΟΧΑΣ

If I remove for example the record ΑΧΑΡΝΩΝ, the value of ΧΑΝΙΩΝ works properly.

Has google set limits on search through Geocoding Service?

Is this because I haven't bought an API KEY?

Thanks in advance!

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 );
        }
    });
}
  • 1
    Log the `status` returned by the service when you detect an error. The geocoder has a quota and a rate limit. After the first ~10 results, you need to honor the rate limit. There are lots of duplicate questions if you search for how to handle status="OVER_QUERY_LIMIT`. – geocodezip May 26 '20 at 14:14
  • 2
    Duplicate of [How do I Geocode 20 addresses without receiving an OVER\_QUERY\_LIMIT response?](https://stackoverflow.com/questions/2419219/how-do-i-geocode-20-addresses-without-receiving-an-over-query-limit-response) – MrUpsidown May 26 '20 at 14:29

1 Answers1

1

While there will be for sure limits in the API calls you can make against the geocoding service of google maps, probably you could take a look at the error code you are getting back in order to understand what is going on. More details for what you understand is "google giving you an error" would be great.

From their documentation, you can find the error codes here https://developers.google.com/maps/documentation/javascript/geocoding?hl=es#GeocodingStatusCodes

If you would be going over quota you would see "OVER_QUERY_LIMIT" for example...

If an error just means that that city has no results maybe it's just giving you back a "ZERO_RESULTS" and you are not parsing properly the rest and your JS fails

Alejandro Vales
  • 2,816
  • 22
  • 41