Android Google autocomplete place api我想设置一个特定的状态,即sate get only city

Android Google autocomplete place api我想设置一个特定的状态,即sate get only city,android,google-maps,Android,Google Maps,我想在google auto complete place api中设置特定状态。我只指定了我想要得到的城市或地区的哪个州作为响应。即 我在状态中指定gujrat,所以只获取gujrat的位置。你能帮我吗 试试这个 function initialize() { var options = { types: ['(cities)'], componentRestrictions: {country: "us"} }; var input

我想在google auto complete place api中设置特定状态。我只指定了我想要得到的城市或地区的哪个州作为响应。即 我在状态中指定gujrat,所以只获取gujrat的位置。你能帮我吗

试试这个

function initialize() {

     var options = {
      types: ['(cities)'],
      componentRestrictions: {country: "us"}
     };

     var input = document.getElementById('searchTextField');
     var autocomplete = new google.maps.places.Autocomplete(input, options);
    }
您可以使用绑定:

var southWest = new google.maps.LatLng(sw_latitude, sw_longitude ); //South West Lat Lng
var northEast = new google.maps.LatLng(ne_latitude, ne_longitude ); //North East Lat Lng
var gujaratBounds = new google.maps.LatLngBounds( southWest, northEast );

var options = {
    bounds: gujaratBounds,
    types: ['(cities)'],
    componentRestrictions: { country: 'in' }
};
更多


谢谢我在安卓系统中使用如何使用bounds@MehulTank,按照此操作,您可以从中找到绑定值:我们也搜索它,我在一个站点中找到,它也为我工作链接-