3

Labé is a city in Guinea. It is the capital of the Labé region and the Labé prefecture

When I use the Google Geocoder API to geocode [labe] with no filters, I get three results in Guinea: One for the locality, one for the level 1 admin area, and one for the level 2 admin area:

https://maps.googleapis.com/maps/api/geocode/json?address=labe

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Labé",
               "short_name" : "Labé",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Guinea",
               "short_name" : "GN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Labé, Guinea",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 12.4428371,
                  "lng" : -11.109311
               },
               "southwest" : {
                  "lat" : 11.0049169,
                  "lng" : -13.027551
               }
            },
            "location" : {
               "lat" : 11.641159,
               "lng" : -11.8891721
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 12.4428371,
                  "lng" : -11.109311
               },
               "southwest" : {
                  "lat" : 11.0049169,
                  "lng" : -13.027551
               }
            }
         },
         "types" : [ "administrative_area_level_1", "political" ]
      },
      {
         "address_components" : [
            {
               "long_name" : "Labe",
               "short_name" : "Labe",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Labé Prefecture",
               "short_name" : "Labé Prefecture",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Labé",
               "short_name" : "Labé",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Guinea",
               "short_name" : "GN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Labe, Guinea",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 11.3544994,
                  "lng" : -12.2434901
               },
               "southwest" : {
                  "lat" : 11.2847299,
                  "lng" : -12.3362733
               }
            },
            "location" : {
               "lat" : 11.316667,
               "lng" : -12.283333
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 11.3544994,
                  "lng" : -12.2434901
               },
               "southwest" : {
                  "lat" : 11.2847299,
                  "lng" : -12.3362733
               }
            }
         },
         "types" : [ "locality", "political" ]
      },
      // (omitted result for Elbe)
      {
         "address_components" : [
            {
               "long_name" : "Labé Prefecture",
               "short_name" : "Labé Prefecture",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "Guinea",
               "short_name" : "GN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Labé Prefecture, Guinea",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 11.739439,
                  "lng" : -11.994902
               },
               "southwest" : {
                  "lat" : 11.140461,
                  "lng" : -12.605376
               }
            },
            "location" : {
               "lat" : 11.3541939,
               "lng" : -12.3463875
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 11.739439,
                  "lng" : -11.994902
               },
               "southwest" : {
                  "lat" : 11.140461,
                  "lng" : -12.605376
               }
            }
         },
         "types" : [ "administrative_area_level_2", "political" ]
      }
   ],
   "status" : "OK"
}

When I narrow by country, however, I only receive the level 1 admin area (region):

https://maps.googleapis.com/maps/api/geocode/json?address=labe&components=country:gn

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "Labé",
               "short_name" : "Labé",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "Guinea",
               "short_name" : "GN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "Labé, Guinea",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 12.4428371,
                  "lng" : -11.109311
               },
               "southwest" : {
                  "lat" : 11.0049169,
                  "lng" : -13.027551
               }
            },
            "location" : {
               "lat" : 11.641159,
               "lng" : -11.8891721
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 12.4428371,
                  "lng" : -11.109311
               },
               "southwest" : {
                  "lat" : 11.0049169,
                  "lng" : -13.027551
               }
            }
         },
         "types" : [ "administrative_area_level_1", "political" ]
      }
   ],
   "status" : "OK"
}

Generally the geocoder API seems to have trouble with cities that share their names with administrative regions; neither of these searches return locality results, only admin areas:

Any idea what gives? Google knows about these cities - if you search using the Maps interface, it finds them immediately.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.