https://google-developers.appspot.com/maps/documentation/javascript/examples/places-autocomplete
I have a page similar to the above google places autocomplete demo url whereby if i type Buckingham Palace. It will return results of
- Buckingham Palace Road, London, United Kingdom
- Buckingham Palace Shop, Buckingham Palace Road, Victoria, London, United Kingdom
and etc. How do i remove London, United Kingdom from the results?
This is not possible without manually processing the results. If you think that it would be a useful feature, please file a Places API - Feature Request.
It seems Google have no interest in sorting it out anytime soon. I have had to resort to the following, might be sufficient for others' needs as well:
note that
pac-item
is the class used on each suggestion. See Google Reference for other classes used. The container withpac-container
class seems to drop the items when it is not shown and add new ones when it displays so if thesepac-items
are getting added to the DOM, it means suggestions are on their way to be displayed andpac-container
is about to become visible.just worked this out so open to improvements.
This also is not a complete solution. When selecting a suggestion with the country removed, autocomplete still adds the country to the geocoding!
place_changed
is too late a stage to change that so please see the solution above as only part of the answer. I'll update this again once I figure out the rest.--- update
personally, i ended up not using the google autocomplete at all as i couldn't find a way around the problem of the autocomplete still showing the country once a modified suggestion is selected. a more usable approach was to use twitter typeahead and use the google APIs for getting the suggestions only. this gave me more control over the suggestions but obviously requires more manual work to make up for lost functionality
Here is How I made it work with jQuery auto-complete. Hope it helps someone.