Categories: softare development

How to Use Google Places AutoComplete in React Native

The Google Places Autocomplete feature in mobile software development is useful for searching for verified locations that are available on Google Maps.

In this tutorial, we are going to see how we can use the Google Places Autocomplete feature in our React Native application.

Let’s get started!

1. Obtain an API key from Google Cloud Console

First you need to add billing to your Google Cloud Console account and enable Geocoding.

2. Install the Google Places AutoComplete dependency

Read more about the Google AutoComplete dependency

yarn add react-native-google-places-autocomplete

3. Add code for the Google API

<GooglePlacesAutocomplete
    placeholder='Search location'
    returnKeyType={'default'}
    fetchDetails={true}
    currentLocation = {true}
    isRowScrollable={true}
    keepResultsAfterBlur={false}
    enablePoweredByContainer = { false }
    styles={{
      textInputContainer: {
        marginTop: 0,
      },
      textInput: {
        height: 45,
        color: 'black',
        fontSize: 16,
        backgroundColor: '#ddd'
      },
      predefinedPlacesDescription: {
        color: '#1faadb',
      },
      listView: {
        position: 'relative',
        zIndex: 3,
        marginTop: 0,
        padding: 0
      },
      row: {
      backgroundColor: '#FFFFFF',
      height: 100,
      flexDirection: 'row',
      },
      separator: {
      height: 0.5,
      backgroundColor: '#c8c7cc',
      },
      description: {},
      loader: {
      flexDirection: 'row',
      justifyContent: 'flex-end',
      height: 20,
      },
    }}

    onPress={(data, details) => {
      // 'details' is provided when fetchDetails = true
      // console.warn(details);
    }}
    query={{
      key: API_KEY,
      language: 'en',
      components: 'country:us'
    }}
    />

Result:

Did it work out for you? Let me know in the comments.

Don’t build mobile apps from scratch

Recent Posts

Instagram Extends Reels Duration to 3 Minutes

Regardless of whether TikTok faces a U.S. ban, Instagram is wasting no time positioning itself…

1 day ago

AWS Expands Payment Options for Nigerian Customers, Introducing Naira (NGN) for Local Transactions

Amazon Web Services (AWS) continues to enhance its customer experience by offering more flexible payment…

5 days ago

Why JavaScript Remains Dominant in 2025

JavaScript, often hailed as the "language of the web," continues to dominate the programming landscape…

7 days ago

Amazon Moves to Upgrade Alexa with Generative AI Technology

Amazon is accelerating efforts to reinvent Alexa as a generative AI-powered “agent” capable of performing…

1 week ago

Smuggled Starlink Devices Allegedly Used to Bypass India’s Internet Shutdown

SpaceX's satellite-based Starlink, which is currently unlicensed for use in India, is reportedly being utilized…

1 week ago

Why Netflix Dumped React For its Frontend

Netflix, a pioneer in the streaming industry, has always been at the forefront of adopting…

1 week ago