Skip to content

A .NET plugin to make it easy to use the Google Places Api.

License

Notifications You must be signed in to change notification settings

jacobduijzer/GooglePlacesApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

A .NET plugin to make it easy to use the Google Places Api.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages