react-google-autocomplete

React component for google autocomplete.

Github stars Tracking Chart

React google autocomplete

This is a simple react component for working with google autocomplete

Install

npm i react-google-autocomplete --save

You also have to include google autocomplete link api in your app. Somewhere in index.html or somwhere else.

  <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=[YOUR_API_KEY]&libraries=places"></script>

Example

import Autocomplete from 'react-google-autocomplete';

<Autocomplete
    style={{width: '90%'}}
    onPlaceSelected={(place) => {
      console.log(place);
    }}
    types={['(regions)']}
    componentRestrictions={{country: "ru"}}
/>

The component has one function called onPlaceSelected. The function gets invoked every time a user chooses location.
A types props means type of places in google place API. By default it uses (cities).
A componentRestrictions prop by default is empty.
A bounds prop by default is empty.
You also can pass any props you want to the final input. You can also set fields prop if you need extra information, now it defaults to basic data in order to control expenses.

Contribution

If you would like to see something in this library please create an issue and I will implement it as soon as possible.

Main metrics

Overview
Name With OwnerErrorPro/react-google-autocomplete
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2016-05-21 11:31:32
Pushed At2025-04-03 13:20:08
Last Commit At2025-04-03 15:17:37
Release Count16
Last Release Namev2.6.1 (Posted on )
First Release Namev2.0.0 (Posted on )
用户参与
Stargazers Count495
Watchers Count7
Fork Count120
Commits Count123
Has Issues Enabled
Issues Count197
Issue Open Count46
Pull Requests Count43
Pull Requests Open Count2
Pull Requests Close Count9
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private