Skip to content

Commit aa4de24

Browse files
Merge pull request #380 from ACHP/Adding-GooglePlacesDetails-props
Add possibility to specify options for the googlePlacesDetails query
2 parents 11149dd + 7c2f194 commit aa4de24

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

GooglePlacesAutocomplete.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ export default class GooglePlacesAutocomplete extends Component {
286286
key: this.props.query.key,
287287
placeid: rowData.place_id,
288288
language: this.props.query.language,
289+
...this.props.GooglePlacesDetailsQuery,
289290
}));
290291

291292
if (this.props.query.origin !== null) {
@@ -759,6 +760,7 @@ GooglePlacesAutocomplete.propTypes = {
759760
query: PropTypes.object,
760761
GoogleReverseGeocodingQuery: PropTypes.object,
761762
GooglePlacesSearchQuery: PropTypes.object,
763+
GooglePlacesDetailsQuery: PropTypes.object,
762764
styles: PropTypes.object,
763765
textInputProps: PropTypes.object,
764766
enablePoweredByContainer: PropTypes.bool,
@@ -808,6 +810,7 @@ GooglePlacesAutocomplete.defaultProps = {
808810
types: 'geocode',
809811
},
810812
GoogleReverseGeocodingQuery: {},
813+
GooglePlacesDetailsQuery: {},
811814
GooglePlacesSearchQuery: {
812815
rankby: 'distance',
813816
type: 'restaurant'

GooglePlacesAutocompleteExample/Example.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var Example = React.createClass({
4141
color: '#1faadb',
4242
},
4343
}}
44-
44+
4545
currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
4646
currentLocationLabel="Current location"
4747
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
@@ -53,16 +53,19 @@ var Example = React.createClass({
5353
rankby: 'distance',
5454
types: 'food',
5555
}}
56-
57-
56+
GooglePlacesDetailsQuery={{
57+
// available options for GooglePlacesDetails API : https://developers.google.com/places/web-service/details
58+
fields: 'formatted_address',
59+
}}
60+
5861
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
59-
62+
6063
predefinedPlaces={[homePlace, workPlace]}
61-
64+
6265
predefinedPlacesAlwaysVisible={true}
6366
/>
6467
);
6568
}
6669
});
6770

68-
module.exports = Example;
71+
module.exports = Example;

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ const GooglePlacesInput = () => {
6868
rankby: 'distance',
6969
type: 'cafe'
7070
}}
71+
72+
GooglePlacesDetailsQuery={{
73+
// available options for GooglePlacesDetails API : https://developers.google.com/places/web-service/details
74+
fields: 'formatted_address',
75+
}}
7176

7277
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
7378
predefinedPlaces={[homePlace, workPlace]}

0 commit comments

Comments
 (0)