Search code examples
laravelgoogle-mapsgeocodinglaravel-5.4google-geocoder

Geocoder returns USA results when GB is being specified


I am using a Laravel plugin to geocode a city into latitude and longitude.

This is what is sent:

$param = [ 'address' => $place, 'country:GB', 'types' => ["cities"] ];

Unfortunately, Google keeps returning all of the results from USA, not GB!

I have added the country and types into a components array, and it still returns USA results.

Any help would be hugely appreciated.


Solution

  • you're sending the country wrong. in the docs:

    To restrict your results to a specific area use component filter Component Filtering by adding it's filters to parameter array.

    $param = array(
                "address"=>"76 Buckingham Palace Road London SW1W 9TQ",
                "components"=>"country:GB"
            );