Skip to content

Commit b05e0e0

Browse files
committed
feat: add options to autocomplete constructor
option to be used in autocomplete constructor. see more about [here](https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete) resolves #72
1 parent 429b0c7 commit b05e0e0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ A `types` props means type of places in [google place API](https://developers.go
3232
A [componentRestrictions](https://developers.google.com/maps/documentation/javascript/reference#ComponentRestrictions) prop by default is empty.
3333
A [bounds](https://developers.google.com/maps/documentation/javascript/reference#AutocompleteOptions) prop by default is empty.
3434
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.
35+
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)
3536

3637
## Contribution
3738

src/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ import PropTypes from 'prop-types';
44
export default class ReactGoogleAutocomplete extends React.Component {
55
static propTypes = {
66
onPlaceSelected: PropTypes.func,
7-
types: PropTypes.array,
7+
types: PropTypes.arrayOf(PropTypes.string),
88
componentRestrictions: PropTypes.object,
99
bounds: PropTypes.object,
1010
fields: PropTypes.array,
1111
inputAutocompleteValue: PropTypes.string,
12+
options: PropTypes.shape({
13+
componentRestrictions: PropTypes.object,
14+
bounds: PropTypes.object,
15+
location: PropTypes.object,
16+
offset: PropTypes.number,
17+
origin: PropTypes.object,
18+
radius: PropTypes.number,
19+
sessionToken: PropTypes.object,
20+
types: PropTypes.arrayOf(PropTypes.string)
21+
}),
1222
};
1323

1424
constructor(props) {
@@ -27,9 +37,11 @@ export default class ReactGoogleAutocomplete extends React.Component {
2737
'geometry.location',
2838
'place_id',
2939
'formatted_address'
30-
]
40+
],
41+
options = {}
3142
} = this.props;
3243
const config = {
44+
...options,
3345
types,
3446
bounds,
3547
fields
@@ -84,6 +96,7 @@ export default class ReactGoogleAutocomplete extends React.Component {
8496
types,
8597
componentRestrictions,
8698
bounds,
99+
options,
87100
...rest
88101
} = this.props;
89102

0 commit comments

Comments
 (0)