Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 2.88 KB

README.md

File metadata and controls

60 lines (44 loc) · 2.88 KB

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!