2016-09-14 56 views

回答

0

您可以使用類似於以下內容的代碼將搜索限制在某個國家/地區。

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=your-key"></script> 
    <label for="city"> 
     <input id="city" name="city"> 
    </label> 

    <script> 
     var input = document.getElementById('city'); 
     var options = { 
      types: ['(cities)'], 
      componentRestrictions: {country: "us"} 
     }; 
     var searchBox = new google.maps.places.SearchBox(input,options); 
    </script> 

更多代碼可以發現here

相關問題