Code Monkey home page Code Monkey logo

googleplacesapi's Introduction

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!

googleplacesapi's People

Contributors

jacobduijzer avatar martijnvanandel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

googleplacesapi's Issues

GetDetailsAsync ignores Language Setting

The following call always returns all values in english, even though the language is configured to de.

PlaceID: ChIJiThxhEGHbUcR4B7mLVeXAAQ
image

image

Calling the API via the right parameters in Postman returns the expected results:

https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJiThxhEGHbUcR4B7mLVeXAAQ&language=de&fields=formatted_address,name&key=<key>

{
    "html_attributions": [],
    "result": {
        "formatted_address": "St. Pölten, Österreich",
        "name": "Sankt Pölten"
    },
    "status": "OK"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.