问题
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
回答1:
For resolve it, just add this query param ®ion=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®ion=de"></script>
It helped me.
来源:https://stackoverflow.com/questions/48080596/google-places-autocomplete-suggestion-without-country-name