Reputation: 42464
I want to filter geo autocomplete to only USA addresses/cities. How can I do that?
using
google geo autocomplete and google maps v2
Upvotes: 1
Views: 1065
Reputation: 872
Google Maps API V3 makes this very easy with their Autocomplete class. To see it in action, look at the source code of this page. One of the nice things it does is biases the search results based on the current view of the map. So if you set your center point to something like "39, -97" (somewhere in Kansas...) and set the zoom to 3 or 4 when you initialize your map, it will start up with the entire US in focus and will bias the search results accordingly. Just search for the words "center" and "zoom" in the source of the page I linked to above to see where to set those.
If you want to manually set the bias boundaries, have a look at the setBounds method of the Autocomplete class, or set it in the constructor using an AutocompleteOptions object.
Hope this helps.
Upvotes: 0
Reputation: 4583
$('#demo3_location').geo_autocomplete({
geocoder_region: 'United States',
geocoder_types: 'states',
mapheight: 100, mapwidth: 200, maptype: 'hybrid'
});
Something like that. You can check out the documentation if you need more help: http://code.google.com/p/geo-autocomplete/
Upvotes: 0
Reputation: 4583
Only put US geo information in your autocomplete array/script/json.
Upvotes: 1