Lightweight C# wrapper for Google Places API.
// Install release version
Install-Package GooglePlaces.Xamarin
- .NET 4.5+
- ASP.Net Core 1.0
- Xamarin Android
- Xamarin iOS
- Xamarin iOS Classic
- Windows 8
You will need your own valid Google API and project setup via the Google Developers Console.
-
Log in to Google Developer Console
-
Create a new project.
-
Add a "Browser" API Key under Credentials.
PlacesAutocomplete autocompleteObject = new PlacesAutocomplete("YOUR API KEY");
Predictions predictions = await autocompleteObject.GetGoogleAutoComplete("SEARCH INPUT");
foreach (var prediction in predictions.predictions) {
var description = prediction.Description;
var place_id = prediction.Place_id;
var id = prediction.Id;
var reference = prediction.Reference;
var terms = prediction.Terms;
var type = prediction.Types;
}
View prediction definitions at Google Places API
PlacesGeocode geocodeObject = new PlacesGeocode("YOUR API KEY");
Geocode response = await geocodeObject.GetGeocode("ADDRESS");
foreach (var results in response.results) {
var location = results.geometry.location;
var lat = location.lat;
var lng = location.lng;
...
}