1.0.1 • Published 3 years ago

@bhl09/react-google-places-text-search v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Google Places Text Search

A Fork from tintef/react-google-places-autocomplete to utilise to change the search from autocomplete to text search with multiple types.

Getting started

Install the latest version:

npm install --save @bhl09/react-google-places-text-search
  or
yarn add @bhl09/react-google-places-text-search

Text Search with single or multiple types

import React from 'react';
import GooglePlacesTextSearch from 'react-google-places-text-search';

const Component = () => (
  <div>
    <GooglePlacesTextSearch
      apiKey="****"
      textSearchRequest={{
          componentRestrictions: { country: 'au' },
      }}
      types={['gas_station','supermarket','home_goods_store']}
    />
  </div>
);

export default Component;

Refer to Place type 1 for full list of types.

Refer to TextSearchRequest interface for SearchRequest properties.

Note: As Google Places API doesn't allow multiple types in one API call, it will be a separate API call for each type (i.e. 3 types = 3 API calls).

Note: Do NOT use type property of SearchRequest interface. The types property of the GooglePlacesTextSearch component will handle it.

Original (Autocomplete)

import React from 'react';
import GooglePlacesAutocomplete from 'react-google-places-autocomplete';

const Component = () => (
  <div>
    <GooglePlacesAutocomplete
      apiKey="****"
    />
  </div>
);

export default Component;

Coming from v2? Check the migration guide

Documentation

Read The Docs

How to contribute?

  1. Fork this repo
  2. Clone your fork
  3. Code 🤓
  4. Test your changes

    For this, I like to use yalc, as it allows to emulate the process of using npm/yarn.

    1. Install yalc
    2. Build project with yarn build or npm run build
    3. Publish the package with yalc: yalc publish
    4. Add the package to your test project yalc add react-google-places-automocomplete
    5. If needed, to update the package on your test project: yalc update react-google-places-autocomplete
  5. Submit a PR!