react-native-google-places-autocomplete
Customizable Google Places autocomplete component for iOS and Android React-Native apps
Preview
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
Example
import React from 'react';import Image Text from 'react-native';import GooglePlacesAutocomplete from 'react-native-google-places-autocomplete'; const homePlace = description: 'Home' geometry: location: lat: 488152937 lng: 24597668 ;const workPlace = description: 'Work' geometry: location: lat: 488496818 lng: 22940881 ; const GooglePlacesInput = return <GooglePlacesAutocomplete ='Search' = // = = // //..///.# = // //..///.# ='auto' // // = = // = = = = = // 'Current location' ="Current location" ='GooglePlacesSearch' // = = = = // - ['locality', 'administrative_area_level_3'] = = // . . . = = /> ;
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) |
separator | object (View style) |
row | object (View style) |
Example
<GooglePlacesAutocomplete ='Enter Location' = = = = = =/>
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
Changelog
- 1.3.9 : Multiple bugfixes + fixed breaking change in React Native.
- 1.3.6 : Fixed accuracy issue.
- 1.3.5 : Fixed bug where input was being cleared.
- 1.3.4 : Fixed bug where loading was breaking the component.
- 1.3.3 : Fixed
key prop
warning and added loading indicator. - 1.3.2 : Added small feature which makes the request on
componentDidMount()
when you already have the default value set. - 1.3.1 : Update
react-native
peerDependecy. (> 0.46) - 1.3.0 : Added support for React 16 (isMounted() and propTypes bugfix), support for restricted API key and moving from
ListView
toFlatlist
. - 1.2.12 : Fixed render description + docs.
- 1.2.11 : Fixed current location result
onPress
event. - 1.2.10 : Set default
debounce
to0
. Fixed debounce typing lag. - 1.2.9 : Added
isRowScrollable
prop. - 1.2.8 : Added
underlineColorAndroid
,listUnderlayColor
,renderLeftButton
,renderRightButton
props. AddednearbyPlacesAPI
optionNone
.