1
我有下面的代碼,我已經操縱了一段時間,但我根本無法得到它的返回結果..自動完成國家列表使用谷歌地圖API
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var options = {
types: ['(cities)'],
componentRestrictions: {country: "us"}
};
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input , options);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div class = "row">
<input id="searchTextField" type="text" size="50" placeholder="Enter a location" autocomplete="on">
</div>
</body>
使用上面的代碼,我可以得到特定國家的城市列表。但我的要求是我需要單獨獲取國家名單。
如果選項未通過,則所有地點都會返回爲結果。
有沒有辦法單獨過濾國家?如果您有任何解決方案,請幫助我。
非常感謝您的快速回復。我想我需要嘗試一下你提到的替代解決方案。非常感謝。 – Mahahari
任何人都可以提供任何代碼片段或使用其他解決方案檢索國家列表的任何想法?請幫助 – Mahahari