Code Monkey home page Code Monkey logo

node-google-place's Introduction

@gojob/google-place

travis build Coverage Status

Description

This package is a library for Node.js to consume the Google Place autocomplete & details API. It returns a small subset of their data.

Installation

yarn add @gojob/google-place

Usage

import * as gp from '@gojob/google-place';

Autocomplete API

const results = await gp.autocomplete({
    key: 'YOUR_API_KEY',
    input: 'Port-de-Bouc',
    language: 'fr',
    countries: ['fr'],
});

gp.autocomplete(query)

Name Type Description
key string Google API Key
input string Searched entry
language string Language to use (optional) Google Code
countries string[] Filter on a country (optional) ISO 3166-1 Alpha-2

Returns a list of prediction or throw if an error occurred.

interface IPrediction {
  id: string;
  name: string;
}

As:

Name Type Description
id string Place id
name string Place name

gp.retrieve(query)

const place  gp.retrieve({
    key: 'YOUR_API_KEY',
    id: 'ChIJ-RzUxt8ethIRksIaOl-0tJY',
    language: 'fr',
});

As:

Name Type Description
key string Google API Key
id string Searched entry
language string Language to use (optional) Google Code

Returns a place or throw if an error occurred.

export interface ILocation {
  lat: number;
  lng: number;
}

export interface IPlace {
  id: string;
  address: string;
  location: ILocation;
  postalCode: string;
  locality: string;
  administrativeAreaLevel1: string;
  administrativeAreaLevel2: string;
  countryCode: string;
  country: string;
}

As:

Name Type Description
id string Place id
address string Formatted address
location object Latitude and longitude coordinates
postalCode string Postal code
locality string Locality name (long or short name)
administrativeAreaLevel1 string Administrative Area Level 1 (long or short name)
administrativeAreaLevel2 string Administrative Area Level 2 (long or short name)
countryCode string Country short name
country string Country name (long name)

postalCode, administrativeAreaLevel1 or administrativeAreaLevel2 may be empty string

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.