Reputation: 195
i want to set specific state in google auto complete place api. which state i specify only that state of city or area i want to get in response. i.e i specify gujrat in state so get only location of gujrat only . can help me out.
Upvotes: 1
Views: 2227
Reputation: 320
Try this,
function initialize() {
var options = {
types: ['(cities)'],
componentRestrictions: {country: "us"}
};
var input = document.getElementById('searchTextField');
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
you can use 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' }
};
for more,
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-hotelsearch
https://developers.google.com/places/web-service/autocomplete
Upvotes: 2