Socket
Socket
Sign inDemoInstall

google-places-suggester

Package Overview
Dependencies
253
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    google-places-suggester

You can use the google places auto complete feature by passing your google api key as prop.


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Google Places Auto Complete

npm install google-places-suggester

React Places Autocomplete

A React component to build a customized UI for Google Maps Places Autocomplete

  1. Enable you to easily build a customized autocomplete dropdown powered by Google Maps Places Library
  2. Utility functions to geocode and get latitude and longitude using Google Maps Geocoder API
  3. Full control over rendering to integrate well with other libraries (e.g. Redux-Form)
  4. Mobile friendly UX
  5. WAI-ARIA compliant
  6. Support Asynchronous Google script loading

Installation

To install the stable version

npm install --save google-places-suggester

React component is exported as a default export

import AddressAutoComplete from "google-places-suggester";

utility functions are named exports

Getting Started

Create your component

import React from "react";
import PlacesAutocomplete from "google-places-suggester";

<AddressAutoComplete
  google_api_key={"YOUR_API_KEY"}
  allowedCountries={["Array of allowed country codes"]}
  seperatedAddress={true | false}
/>;

Props

PropTypeRequiredDescription
google_api_keystring:white_check_mark:The Google API key to be used to show suggestions.
allowedCountriesstring[]An array of country codes to allow. Use an empty array to allow all countries.
separatedAddressbooleanIf true, the address will be returned as an object containing address, postalCode, city, country, and state separately. If false, it will only return an object with the address.
onChangefunction:white_check_mark:Callback function to handle input changes.
labelstringLabel for the input field.
classNamestringCSS class name for styling.
stylesObjectCSS styles for customization.
onFocusfunctionCallback function when the input field is focused.
onBlurfunctionCallback function when the input field loses focus.
defaultValuestringDefault input value.
valuestringInput value.
refObjectReference object for accessing the input element.
disabledbooleanIf true, the input is disabled.
onPastefunctionCallback function for handling paste events.
requiredbooleanIf true, the input is required.
<AddressAutoComplete
  google_api_key={"YOUR_API_KEY"}
  allowedCountries={["Array of allowed country codes"]}
  seperatedAddress={true | false}
  onChange={(value) => this.setState({ value })}
/>

FAQs

Last updated on 21 Sep 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