Buxte
Buxte

Reputation: 31

Google places autocomplete suggestion without country name

I am looking for a possibility to get suggestions without country name.

I have the following js code:

... var autocomplete_pickup = new google.maps.places.Autocomplete(pickup_field, {
       types: ["address"], componentRestrictions: {country: "de"}
}); ...

The result is e.g.

Bahnhofstrasse 4, Hamburg, Deutschland

Now I want to have for that example only

Bahnhofstrasse 4, Hamburg

I have limited the countries only to Germany and therefore is not necessary to show the country name.

Do you have an idea? Thanks. Heinz-Peter

Upvotes: 3

Views: 816

Answers (1)

Alex McDee
Alex McDee

Reputation: 31

For resolve it, just add this query param &region=de into your script path

It seems like this:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=[API-KEY]&libraries=places&region=de"></script>

It helped me.

Upvotes: 3

Related Questions