You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-12Lines changed: 29 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## React google autocomplete
2
2
3
-
This is a simple react component for working with google [autocomplete](https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete)
3
+
This is a simple react component for working with google [autocomplete](https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete)
4
4
5
5
## Install
6
6
@@ -13,37 +13,54 @@ As of version 1.2.4, you can now pass an `apiKey` prop to automatically load the
13
13
```js
14
14
<AutoComplete
15
15
apiKey={YOUR_GOOGLE_MAPS_API_KEY}
16
-
onPlaceSelected={() =>'do something on select'}
16
+
onPlaceSelected={() =>"do something on select"}
17
17
/>
18
18
```
19
19
20
20
Alternatively if not passing the `apiKey` prop, you can include google autocomplete link api in your app. Somewhere in index.html or somewhere else.
We are planning on adding a full support for TS and Flow in the later releases.
47
+
48
+
```js
49
+
import Autocomplete, {
50
+
ReactGoogleAutocomplete,
51
+
} from"react-google-autocomplete";
52
+
53
+
const AutocompleteTS:FC<ReactGoogleAutocomplete> = Autocomplete as FC<ReactGoogleAutocomplete>;
54
+
55
+
<AutocompleteTS key="123"/>
39
56
```
40
57
41
58
The component has one function called `onPlaceSelected`. The function gets invoked every time a user chooses location.
42
59
A `types` props means type of places in [google place API](https://developers.google.com/places/web-service/autocomplete#place_types). By default it uses (cities).
43
60
A [componentRestrictions](https://developers.google.com/maps/documentation/javascript/reference#ComponentRestrictions) prop by default is empty.
44
61
A [bounds](https://developers.google.com/maps/documentation/javascript/reference#AutocompleteOptions) prop by default is empty.
45
62
You also can pass any props you want to the final input. You can also set [fields](https://developers.google.com/maps/documentation/javascript/reference/places-service#PlaceResult) prop if you need extra information, now it defaults to basic data in order to control expenses.
46
-
The `options`(optional) prop is the optional configuration to your Autocomplete instance. You can see full options [here](https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete)
63
+
The `options`(optional) prop is the optional configuration to your Autocomplete instance. You can see full options [here](https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete)
0 commit comments