Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tasiodev/react-places-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tasiodev/react-places-autocomplete

Component used as a field in a form to autocomplete a place, using the Google Maps API.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61
decreased by-46.02%
Maintainers
1
Weekly downloads
 
Created
Source

React Places Autocomplete

Component used as a field in a form to autocomplete a place, using the Google Maps API.

The place can be a city, a country, a street, or even an establishment.

alt text

Demo

https://react-places-autocomplete-demo.up.railway.app

Features

  • Map with the selected place
  • Limit the type of places you want to retrieve
  • Fully customizable

Requisites

To use this component, you will need a Google API key. Here is more information on how to obtain it: https://developers.google.com/maps/documentation/javascript/get-api-key

You will also need to enable these two APIs:

  • Places API
  • Maps JavaScript API

Exposing your API key in the front-end code of your application can pose significant security risks. Unauthorized access to your API key may lead to unauthorized usage.

Is highly recommended to store it in a separate configuration file, such as the .env file.

Additionally, we strongly recommend that you restrict the usage of your API key using the available configuration options. https://developers.google.com/maps/api-security-best-practices#restrict_apikey

Installation and Basic Example

  npm install @tasiodev/react-places-autocomplete
import { useState } from 'react'
import PlacesPicker from '@tasiodev/react-places-autocomplete'

function App() {
  const [value, setValue] = useState(null)
  return  <PlacesPicker
        gMapsKey='*******************'
        placeId={value}
        onChange={setValue}
      />
}

Props Reference

ParameterTypeDescription
gMapsKeystringRequired. Your API key
placeIdstringId used to load an initial or stored place
onChangefuncEvent triggered when user select a place or when user starts typing to search a place
onSelectPlacefuncEvent triggered when user select a place
placeholderstringPlaceholder for input
searchTypesarray[string]Limit the place types return in a search. See: https://developers.google.com/maps/documentation/places/web-service/supported_types
languagestringISO code for map and results language. Default: "en"
disableMapboolBoolean to disable place Map. Default: false
mapExpandedboolIf true, the map is always visible. Default: false
disabledboolBoolean to disable input
customStylesobjectObject to override styles of each element. See definitions
customStyles example
{
    container: { backgroundColor: 'black' },
    fieldInput: { color: 'red' },
    searchResultsContainer: { marginTop: 12 },
    searchResult: { padding: 6 },
    gmapContainer: { padding: 8, height: 400 },
}

Keywords

FAQs

Package last updated on 27 Jun 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc