2012-04-16 6 views
2

google.maps.places.Autocomplete를 사용 중입니다. 도시에서 자동 완성을 원하지만 Google 문서에서와 같이 자동 완성 결과를 여러 도시로 제한해야합니다.Google 지역 정보 자동 완성

componentRestrictions: {country: "us", "fr"} 

이 시도 : 실제로

componentRestrictions: {country: ["us", "fr"]} 
+0

역설적으로 이것은 국가 별 필터링에 대해 내가 발견 한 첫 번째 예입니다. 감사! 어디서 문서화 작업을 했습니까? – fatfrog

+0

해결 방법 : http://stackoverflow.com/questions/11290755/limit-google-maps-of-countries-in-the-autocomplete-list-to-india-usa-and-uk/36064059#36064059 – metamagicson

답변

1

이 무엇 Places API는 제한으로 1 개의 국가 만 지원합니다. ComponentRestrictions

+0

고마워요. , 아픈 내가 할 수있는 한 빨리 그것을 시도 :) – Francois

3

내가 장소 자동 완성을 Google에 새로운 오전하지만 난 오류가 여기에있다 생각

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places" 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: "us", "fr"} 
    }; 


    var autocomplete = new google.maps.places.Autocomplete(input, options); 
} 
google.maps.event.addDomListener(window, 'load', initialize); 
</script> 

<div> 
<input id="searchTextField" type="text" size="50" placeholder="Enter a location" autocomplete="on"> 
</div> 
관련 문제