react-native-google-places-autocomplete
Customizable Google Places autocomplete component for iOS and Android React-Native apps
Changelog
- 1.2.7 : Use
children
prop to pass children elements directly intoGooglePlacesAutocomplete
. - 1.2.6 : Added
renderRow
prop. - 1.2.5 : Added
renderDescription
prop for rendering dropdown item text - 1.2.4 : Added
listViewDisplayed
prop for controlling dropdown - 1.2.3 : Removed ProgressBarAndroid to remove warnings
- 1.2.2 : Added prop to change placeholder text color
- 1.2.1 : Fixed special request characters issue + ensure react-native@0.28 peer dependency.
- 1.2.0 : Using ActivityIndicator therefore removing deprecation warning. Requires react-native >= 0.28
- 1.1.10 : Update to work with react-native > 0.24
- 1.1.9 : Added
setAddressText
method - 1.1.8 : Ability to set address from outside of component
Example
var GooglePlacesAutocomplete = ; const homePlace = description: 'Home' geometry: location: lat: 488152937 lng: 24597668 ;const workPlace = description: 'Work' geometry: location: lat: 488496818 lng: 22940881 ; var Example = React;
Installation
npm install react-native-google-places-autocomplete --save
- Get your Google Places API keys and enable "Google Places API Web Service" (NOT Android or iOS) in the console.
- Enable "Google Maps Geocoding API" if you want to use GoogleReverseGeocoding for Current Location
Styling
GooglePlacesAutocomplete
can be easily customized to meet styles of your app. Pass styles props to GooglePlacesAutocomplete
with style object for different elements (keys for style object are listed below)
key | type |
---|---|
container | object (View) |
description | object (Text style) |
textInputContainer | object (View style) |
textInput | object (style) |
loader | object (View style) |
listView | object (ListView style) |
predefinedPlacesDescription | object (Text style) |
poweredContainer | object (View style) |
powered | object (Image style) |
Example
<GooglePlacesAutocomplete
placeholder='Enter Location'
minLength={2}
autoFocus={false}
fetchDetails={true}
styles={{
textInputContainer: {
backgroundColor: 'rgba(0,0,0,0)',
borderTopWidth: 0,
borderBottomWidth:0
},
textInput: {
marginLeft: 0,
marginRight: 0,
height: 38,
color: '#5d5d5d',
fontSize: 16
},
predefinedPlacesDescription: {
color: '#1faadb'
},
}}
currentLocation={false}
/>
Features
- Places autocompletion
- iOS and Android compatibility
- Places details fetching + ActivityIndicatorIOS/ProgressBarAndroid loaders
- Customizable using the
styles
parameter - XHR cancellations when typing fast
- Google Places terms compliant
- Current location
- Predefined places