Skip to content
A .NET plugin to make it easy to use the Google Places Api.
C#
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
artwork README + artwork Aug 26, 2018
src Removed the comments of attributes that are not used as input for the… Aug 21, 2019
.gitignore Initial commit Aug 17, 2018
LICENSE Create LICENSE Aug 27, 2018
README.md added badges to readme Aug 22, 2019

README.md

Build status download CodeFactor

GooglePlacesApi

This plugin makes it very easy to use the Google Places API. Please read Jacob Duijzer's blog for the nitty-gritty details.

Usage

The Google Places API needs to be enabled in the developer console and also needs a valid paying account although it can be used without payments, depending of the level of details requested. Read more about billing here.

  1. Create a settings object:
var settings = GoogleApiSettings.Builder
                                            .WithApiKey("api_key")
                                            .WithLanguage("nl")
                                            .WithType(PlaceTypes.Address)
                                            .WithLogger(new ConsoleLogger())
					    .WithDetailLevel(DetailLevel.Basic)
					    .WithSessionToken("YOUR SESSION TOKEN")
                                            .WithOrigin("lat,lon")
					    .WithLocation("lat,lon")
					    .AddCountry("nl")
					    .Build();
  1. Create a service:
var service = new GooglePlacesApiService(settings);
  1. Get predictions:
var result = await service.GetPredictionsAsync("new y").ConfigureAwait(false);
  1. Get details (you can also add a new session token in argument 2, if argument 3 is not given DetailLevel.Basic is used):
var details = await service.GetDetailsAsync("ChIJOwg_06VPwokRYv534QaPC8g", GetSessionToken(), DetailLevel.Full)
                                      .ConfigureAwait(false);
  1. Get photos:
Stream photoStream = await _api.GetPhotoAsync("CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU")
									  .ConfigureAwait(false);

You can choose out of four detail levels, each billed seperately by Google:
a. DetailLevel.Basic
b. DetailLevel.Contact (= Basic + Contact)
c. DetailLevel.Atmosphere (= Basic + Atmosphere)
d. DetailLevel.Full (= Basic + Contact + Atmosphere)

Privacy Policy & Terms

Please read the Google Privacy & Terms and Privacy Policy when you want to use this plugin!

You can’t perform that action at this time.