Thursday, September 27, 2012

Google Places Autocomplete Now Includes Queries

Since we launched the Place Autocomplete feature of the Google Places API, we’ve been excited to see a number of developers use it to make entering addresses into HTML forms quick and easy for users. Today, we aim to delight developers and their users even more by releasing Query Autocomplete, which includes popular queries alongside place and address predictions, and Javascript Autocomplete Data Services, which allows you to style and mix in your own predictions while using the Google Maps JavaScript API.

Query Autocomplete


Google Places Query Autocomplete is a new feature available as part of both the Google Places API and the Google Maps JS API Places Library. This feature has the same type-ahead-search behavior of the original Place Autocomplete, but just like the Google Maps search field, it returns places, addresses, and popular queries, such as “italian restaurants” or “swimming pool.”



Autocomplete Data Services


In the Places Library of the Google Maps JS API, we first offered Place Autocomplete as a drop-down widget that’s bound to an input element. We wanted to give developers more flexibility, so both Place Autocomplete and Query Autocomplete now have data services that return predictions in a JSON collection. With this collection, you have complete control over your text inputting and autocomplete experience while using the Google Maps JS API.

This control allows for mixing in your own predictions, such as the user’s home location or her favorite restaurant, or styling predictions to better match your application. In the demo below, we used the data service to give our predictions some rotating Google-themed colors.



Our Autocomplete services do not need to be used in conjunction with a map, but it does require a “powered by Google” logo to appear under the text field if a map isn’t shown.

The Google Places API autocomplete services are here as part of our goal to make location-based textual input an effortless experience. Give them a try and let us know what you think!

Posted by Paul Saxman, Google Maps Developer Advocate

P.S. Submissions for the Places API Developer Challenge are now open. Build an app to help your community and for a chance to win tickets for Google I/O!