The GPlaces Autocomplete API for WP7 library is compiled for Windows Phone 7.5 (Mango). Typically this library would be combined with the current AutoCompleteBox available in the Silverlight Toolkit. The example project will utilize this control.



Default Usage with no optional parameters


  Add a reference to the GoogleAutoComplete.dll in your WP7 Mango Project. The main class you will be concerned about is the GoogleApi.AutoCompleteRequest class.  Instantiate a new reference to this class passing your google api key as a parameter. A Google API key can be requested here- API Console. The Google Places API only requires the  api key, the string input query and a boolean representing whether the query is originating from a GPS sensor. This is defaulted to true for this library. So a default query with no extra parameters might look like this-

 AutoCompleteRequest auto = new AutoCompleteRequest("your google api key");

 auto.StartAutoCompleteAsync("your query here");

 auto.AutoCompleteRequestCompleted +=delegate(object s, AutoCompleteEventArgs e){

 someControl.ItemsSource = e.Results;

 // e.Results is an ObservableCollection of GoogleApi.Prediction objects. 


Note this usage although allowed by the Google API, will return results from all over the world, with types ranging from businesses, to counties and countries. 

Usage with optional parameters

The Google Places AutoComplete API also allows for a number of optional parameters that greatly increase the effectiveness of the API. In fact a typical location aware autocomplete implementation will likely look something like this-

AutoCompleteRequest auto = new AutoCompleteRequest("your google api key"){

Latitude = 32.2217,   //hopefully retrieved from the GPS sensor

Longitude = -110.9258,

CountryComponent = "US", //limits results to the country code specified

Language = AutoCompleteRequest.LanguageName.English, //specify the default return language (the api will try to return the correct language  based on IP translation anyway but better to be explicit.

Place = AutoCompleteRequest.PlaceType.Establishment, //limit results to businesses

Raduis = 50000  //radius in meters around location to attempt to resolve primary results


auto.AutoCompleteRequestCompleted+=(s,f) => Dispatcher.BeginInvoke(delegate{

somecontrol.ItemsSource = f.Results;




Last edited Apr 13, 2012 at 8:57 PM by bringking, version 2


No comments yet.