Socket
Socket
Sign inDemoInstall

rn-google-places-api-autocomplete

Package Overview
Dependencies
528
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-google-places-api-autocomplete

A customizable autocomplete component made for React Native that interacts with the Google Places API, which has several ways to visualize the places.


Version published
Maintainers
1
Weekly downloads
4
increased by100%

Weekly downloads

Readme

Source

rn-google-places-api-autocomplete

A customizable autocomplete component made for React Native that interacts with the Google Places API, which has several ways to visualize the places.

Alt Text

Installation

Using npm
npm i rn-google-places-api-autocomplete
Using Yarn
yarn add rn-google-places-api-autocomplete
Using pnpm
pnpm add rn-google-places-api-autocomplete

1. Google Places API KEY

Get your Google Places API Key

2. Setup bottom-sheet

GooglePlacesAutocomplete component internally uses @gorhom/bottom-sheet. You need to follow this installation steps

Usage

You can take a look at the example

Configure Bottom sheet modal Provider

If you are going to use the bottom-sheet visualization mode, you need to configure the bottom sheet modal provider, like this:

import React from "react"
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
import { GooglePlacesAutocomplete } from 'rn-google-places-api-autocomplete';

const App = () => {
  return (
    <BottomSheetModalProvider>
      <GooglePlacesAutocomplete visualization="bottom-sheet" apiKey="12345" />
    </BottomSheetModalProvider>
  );
};

More Examples

Controlled Field

Click to expand
import React, { useState } from 'react';
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
import { GooglePlacesAutocomplete, BottomSheetOptionType } from 'rn-google-places-api-autocomplete';

const App = () => {
  const [selectedOption, setSelectedOption] =
    useState<BottomSheetOptionType | null>(null);
  return (
    <GooglePlacesAutocomplete
      visualization='list'
      apiKey='12345'
      onChange={(option) => setSelectedOption(option)}
      selectedOption={selectedOption}
    />
  );
};

Limit results to one country

Click to expand
import React from 'react';
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
import { GooglePlacesAutocomplete } from 'rn-google-places-api-autocomplete';

const App = () => {
  return (
    <BottomSheetModalProvider>
      <GooglePlacesAutocomplete
        visualization='bottom-sheet'
        apiKey='12345'
        query={{
          components: 'country:co', // Limit to Colombia's Places
          types: '(cities)', // Limit search to cities
          language: 'es',// response in spanish
        }}
      />
    </BottomSheetModalProvider>
  );
};

TODO:

  • Improve documentation
    • Add props and methods
    • Add styles customization
  • Add more examples

License

MIT

Authors

Keywords

FAQs

Last updated on 16 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc