Coder Social home page Coder Social logo

tianchengdemo / googleapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vivet/googleapi

0.0 0.0 0.0 2.91 MB

C# .NET Core Google Api (Maps, Places, Roads, Search, Translate). Supports all endpoints and requests / responses.

License: MIT License

C# 100.00%

googleapi's Introduction

Google Api

Build status NuGet NuGet

Seamless Google Api integrations.
Google Maps, Places, Roads, Search and Translate.

Feel free to contribute, throw questions and report issues. I usually respond fast (24-48 hours).
Do you need support for an additional .Net framework?, let me know.

New: Version 5.0.0 with Routes Api (directions and matrix), Ariel View Api and Address Validation Api.


Using the Library

The library may be consumed, either by using the individual facede implementations or by depdendency injecting the individual api's.
Each api implementation consists of a request and a response. The request has properties reflecting the parameters supported, and the response represents the object model for the returned json.

A few other noteworthy members.

var uri = request.GetUri(); // Gets the full request uri, including query parameters.
var params = request.GetQUeryStringParameters(); // Gets a list of all the added parameters.
response.RawJson // The raw json returned by Google.
response.RawQueryString // The querystring sent to Google when invoking the request.

Facade

Each api has a generic facade operation to execute the request and return the response.
The example below, simply populates a request, invokes the facade operation, and receives the response in return.

TRequest request = new TRequest();
TResponse response = await {Api}.[{SubGroup}].{Action}.QueryAsync<TRequest, TResponse>(request);

See below for a full list of supported Api's and actions.

Dependency Injection

If injecting the api's as dependencies is preffered register the services during startup, as shown below.

services
    .AddGoogleApiClients();

Then, inject the individual Api's in constructors as needed

public class MyClass
{
    private {Api}.[{SubGroup}].{Action} api;
    
    public MyClass({Api}.[{SubGroup}].{Action} api)
    {
        this.api = api
    }
}

See below for a full list of supported Api's and actions.

Proxy

If a WebProxy is required set the static property HttpClientFactory.Proxy before registrering the GoogleApi dependencies or using the Facade.


Supported Api's

The following api's are supported.

Google Maps
  • Directions (GoogleMaps.Directions)
  • Distance Matrix (GoogleMaps.DistanceMatrix)
  • Elevation (GoogleMaps.Elevation)
  • Geocode
    • Place (GoogleMaps.Geocode.PlaceGeocode)
    • Address (GoogleMaps.Geocode.AddressGeocode)
    • Location (reverse) (GoogleMaps.Geocode.LocationGeocode)
    • Plus Code (GoogleMaps.Geocode.PlusCodeGeocode)
  • Geolocation (GoogleMaps.Geolocation)
  • Roads
    • Nearest Roads (GoogleMaps.Roads.NearestRoads)
    • Snap To Roads (GoogleMaps.Roads.SnapToRoad)
    • Speed Limits (GoogleMaps.Roads.SpeedLimits)
  • Time Zone
  • Street View
  • Static Maps
  • Routes
    • RouteDirections (GoogleMaps.Routes.Directions)
    • RouteMatrix (GoogleMaps.Routes.Matrix)
  • Address Validation (GoogleMaps.AddressValidation)
  • Aerial View (beta)
    • Directions (GoogleMaps.AerialView.GetVideo)
    • Render Video (GoogleMaps.AerialView.RenderVideo)
Google Places
  • Place Search
    • Find (GooglePlaces.Search.FindSearch)
    • Near By (GooglePlaces.Search.NearBySearch)
    • Text (GooglePlaces.Search.TextSearch)
  • Place Details (GooglePlaces.Details)
  • Place Photos (GooglePlaces.Photos)
  • Place Autocomplete (GooglePlaces.AutoComplete)
  • Query Autocomplete (GooglePlaces.QueryAutoComplete)
Google Search
  • Web (GoogleSearch.WebSearch)
  • Image (GoogleSearch.ImageSearch)
  • Video
    • Channels (GoogleSearch.VideoSearch.Channels)
    • Playlists (GoogleSearch.VideoSearch.Playlists)
    • Vidoes (GoogleSearch.VideoSearch.Vidoes)
Google Translate
  • Detect (GoogleTranslate.Detect)
  • Languages (GoogleTranslate.Languages)
  • Translate (GoogleTranslate.Translate)
Google Functions
  • MergePolyLine
  • EncodePolyLine
  • DecodePolyLine

Running Test Suite

Running the test suite is simple.

The test project stores settings related to your Google subscription (free or paid) in application.default.json.
Most importantly, the ApiKey, used to identify the Google subscription.

{ 
  "ApiKey": "",
  "SearchEngineId": "",
}

More information about generating a key can be found here: https://console.developers.google.com/


googleapi's People

Contributors

vivet avatar dlboutwe avatar mfeingol avatar prologh avatar antmeehan avatar bottlecapdave avatar ewhoambra avatar rangers-globecar avatar cainejette-mojo avatar cainejette avatar dawidmostert avatar meriturva avatar ninjacarr avatar jabez007 avatar jgoyvaerts avatar thespy avatar kadirgedik avatar mcsym28 avatar piofu avatar bobbyangers avatar tmpreston avatar timaxapa avatar vineus avatar wormerr avatar miguelcrpinto-dept avatar

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.