从自动建议列表中删除状态名称,以便用户选择特定的区域/城市 [英] Removing state name from auto suggestion list so that user selects particular area/city
问题描述
我正在使用Google Places API创建文本框,该文本框是用户选择其首选位置的输入字段.我希望该用户指定他居住的确切区域名称.
I am using the google places api to create a textbox that is input field for user to select his/her preferred location. I want that user specifies the exact area name where he lives.
问题是google place api给了我:1.孟买(州名)2.孟买瓦希(孟买市)3.孟买塔那(孟买市)
The problem is google places api gives me: 1.Mumbai (State Name) 2.Mumbai Vashi (City in Mumbai) 3.Mumbai Thane (City in Mumbai)
我要删除第一个选项或所有州名,例如孟买,海得拉巴,卡纳塔克邦,以便用户只能选择自己的地区/城市.
I want to remove the first option OR all the state name like Mumbai, Hyderabad, Karnataka so that user only has choice to select his area/city.
我对UI和Google Places API还是很陌生.请帮忙.
I am fairly new to UI and google places api. Please help.
推荐答案
function initAutocomplete(){
function initAutocomplete() {
var options = {
componentRestrictions: { country: "IN" }
};
// Create the search box and link it to the UI element.
var input = document.getElementById('pac-input');
var searchBox = new google.maps.places.Autocomplete(input, options);
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyD9CiSrNomU7HPw5PLIpFZYP6NXXOq0dlE&libraries=places&callback=initAutocomplete"
async defer></script>
我正在使用google place api javascript.
I am using google places api javascript.
这篇关于从自动建议列表中删除状态名称,以便用户选择特定的区域/城市的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!