我想在google auto complete place api中设置特定状态。哪个州我只指定我希望得到的城市或地区的状态。即 我在州指定gujrat所以只得到gujrat的位置。可以帮助我。
答案 0 :(得分:1)
试试这个,
function initialize() {
var options = {
types: ['(cities)'],
componentRestrictions: {country: "us"}
};
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
你可以使用bound:
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' }
};
了解更多,
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-hotelsearch
https://developers.google.com/places/web-service/autocomplete