このコードは機能していません。正確な解決策を教えてください
<script src="maps.googleapis.com/maps/api/…; type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var input = document.getElementById('searchTextField');
/* restrict to multiple cities? */
var options = {
types: ['(cities)'],
componentRestrictions: {country: ["usa", "uk"]}
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
アップデート
2017 年 1 月に、Maps JavaScript API のバージョン 3.27 で、オートコンプリートの複数の国フィルターが導入されました。
オートコンプリートの予測を、複数の国からのみ表示されるように制限できるようになりました。これを行うには、AutocompleteOptions の componentRestrictions フィールドに最大 5 つの国を指定します。
https://developers.google.com/maps/documentation/javascript/releases#327