I am trying to add an Google Geocode Autocomplete field to my form.
I have been able to get it to restrict the results returned to the country (AU) but it would be even better if I could limit the results to the state as well. (New South Wales/NSW)
This is my current initialize()
function:
function initialize() {
var options = {
types: ['geocode'],
componentRestrictions: {country:"AU"}
};
autocomplete = new google.maps.places.Autocomplete(
(document.getElementById('autocomplete')),options);
google.maps.event.addListener(autocomplete, 'place_changed', function() {
fillInAddress();
});
}
I have read the documentation and found that you can use the types
parameter to restrict the results, but I have been unable to work out what the exact code should be.
Simply changing it to:
types: ['administrative_area1':'NSW'], // OR 'New South Wales'
and various combinations similar to the above (= instead of : etc) have not worked..
Could someone point me in the right direction towards what the actual syntax is for what I am trying to achieve?
Thanks.
administrative_area1
is the state. I am just curious how to use the type parameter to restrict the state returned. – Orestesgeocode, establishment, (cities)
and(regions)
, nothing else. The types-property may not be used to specify the value of a type(e.g. a specific region), it's only meant to filter the results to results that contain the specific component(e.g. a region), it doesn't care about the value of this component. – Grenada