npm package to use material ui autcomplete with google places autocomplete feature
npm install material-ui-autocomplete-google-placesReact component that uses Google Places API AutocompleteService, Google Maps Geocoder, and Material-UI AutoComplete to replicate Google Places Autocomplete search dropdown in Material-UI. Returns latitude and longitude from selected item.
Useful Links:
* Material-UI Autocomplete
* Google Places AutocompleteService
Include script tag in html file:
``html`
Install package:
``
$ npm install material-ui-autocomplete-google-places
Basic Use Case:
`js
import GooglePlaceAutocomplete from 'material-ui-autocomplete-google-places';
class App extends React.Component {
// Results from clicking on location
getCoords(lat, lng){
console.log(lat, lng);
}
render() {
return (
results={this.getCoords}
/>
);
}
}
`
`js
results={this.getCoords}
// AutocompletionRequest object specification
componentRestrictions={{country: 'au'}}
types={['establishment']}
/>
`
* anchorOrigin
* animated - default: true
* animation
* errorStyle
* errorText
* floatingLabelText
* fullWidth - default: true
* hintText - default: ' '
* listStyle
* maxSearchResults
* menuCloseDelay
* menuStyle
* onClose
* open - default: false
* style
* targetOrigin
* textFieldStyle
Edit dropdown menu via:
* menuItemStyle
Defaults for menuItemStyle
```
style={this.props.menuItemStyle || {
fontSize: 13,
display: 'block',
paddingRight: 20,
overflow: 'hidden',
}
See repo for more details.