google_places_flutter icon indicating copy to clipboard operation
google_places_flutter copied to clipboard

How to switch this to multiple country ?

Open aTeamSolace opened this issue 4 years ago • 2 comments

Hello, @yshean your code is working fine. I added my own API key and it's working but it shows only Switzerland country location. why ?. I want to show multiple country locations so how to implement this? can you please help

aTeamSolace avatar Nov 06 '20 15:11 aTeamSolace

In line 49/50 on file google_places_flutter/lib/place_service.dart you can set the property country.

Change final request = 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$input&types=address&language=$lang&components=country:ch&key=$apiKey&sessiontoken=$sessionToken'; to final request = 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$input&key=$apiKey&sessiontoken=$sessionToken';

Then you can search in multi languages and find places all over the world.

dospringer avatar Dec 10 '20 15:12 dospringer

@dospringer 's answer will allow you to search every country available, for language - if it's not specified, then it will attempt to use the native language of the domain from which the request is sent. See the list of supported languages here

yshean avatar Jan 11 '21 13:01 yshean