New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-places-input

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-places-input

Up to date working Google Places Input. Calling directly API not JS SDK.

  • 1.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
56
decreased by-62.67%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Places Input

Up to date working Google Places Input. Calling directly API not JS SDK.

exmaples

Latest changes

1.0.9

Fixing an issue with sometimes not getting details about selected place.

1.0.8

Fixed issue that in some cases list of places is not displayed.

1.0.7

Fixed issue in Android with TouchOpacity not clickable in Scroll View with absolute position.

1.0.6

Bug fixes:

  • Component wont trigger search if input value is empty or after you clear it using text input x

New configuration props:

  • requiredCharactersBeforeSearch - component wont fetch places unless string length is equal this prop. Default 2.
  • requiredTimeBeforeSearch - idle time on text input before component will fetch places.

1.0.5

Remove default props for lat,lng and radius. Add queryCountries where you can pass array of countries to limit your search results.

Installation

yarn add react-native-places-input

or

npm install react-native-places-input

Usage

Fairly easy. Few required props but most of the work is already done in a component.

Basic

import PlacesInput from 'react-native-places-input';

And inside a component

    <PlacesInput
        googleApiKey={GOOGLE_API_KEY}
        onSelect={place => console.log(place}
    />
class InputWrapper extends React.Component {
    render() {
        return (
            <View style={{ width: '100%' }}>
                <PlacesInput
                    googleApiKey={GOOGLE_API_KEY}
                    placeHolder={"Some Place holder"}
                    language={"en-US"}
                    onSelect={place => {
                        this.props.goToPoint(get(place, 'result.geometry.location.lat'), get(place, 'result.geometry.location.lng'))
                    }}
                    iconResult={<Ionicons name="md-pin" size={25} style={styles.placeIcon}/>}
                />
            </View>
        );
    }
}

Configuration props

List of props supported by a component

PropTypeDefaultDescription
googleApiKeyPropTypes.string.isRequired,Google API key
iconInputPropTypes.any,Icon added to an input
iconResultPropTypes.any,Icon added to results
languagePropTypes.string,enLanguage for google API call
placeHolderPropTypes.string,Search places...placeholder for an input
queryFieldsPropTypes.string,formatted_address,geometry,nameFields requested from Google API
queryCountriesPropTypes.arrayArray of country codes to limit results
resultRenderPropTypes.func,place => place.descriptionFunction to render results text
searchLatitudePropTypes.number,Lat to limit results
searchLongitudePropTypes.number,Lng to limit results
searchRadiusPropTypes.number,radius to limit results
stylesContainerPropTypes.object,{}Custom styles for a container
stylesInputPropTypes.object,{}Custom styles for an input
stylesItemPropTypes.object,{}Custom styles for an item
stylesItemTextPropTypes.object,{}Custom styles for an item text
stylesListPropTypes.object,{}Custom styles for a list
stylesLoadingPropTypes.object,{}Custom styles for a loading indicator
textInputPropsPropTypes.object,{}Custom TextInput props
requiredCharactersBeforeSearchPropTypes.number2Component wont fetch places unless string length is equal this prop
requiredTimeBeforeSearchPropTypes.number1000Idle time on text input before component will fetch places
onSelectPropTypes.func,Function called when you select a place

Examples

Inline

exmaples

    <PlacesInput
        placeHolder={'Some placeholder'}
        stylesContainer={{
            position: 'relative',
            alignSelf: 'stretch',
            margin: 0,
            top: 0,
            left: 0,
            right: 0,
            bottom: 0,
            shadowOpacity: 0,
            borderColor: '#dedede',
            borderWidth: 1,
            marginBottom: 10
        }}
        stylesList={{
            top: 50,
            borderColor: '#dedede',
            borderLeftWidth: 1,
            borderRightWidth: 1,
            borderBottomWidth: 1,
            left: -1,
            right: -1
        }}
        googleApiKey={GOOGLE_API_KEY} 
        onSelect={place => this.setState({place})} 
    />

Limit results to a country

    <PlacesInput
        placeHolder={'Some placeholder'}
        queryCountries={['pl', 'fr']}
        googleApiKey={GOOGLE_API_KEY} 
        onSelect={place => this.setState({place})} 
    />

Limit results to a location

    <PlacesInput
        placeHolder={'Some placeholder'}
        searchRadius={500}
        searchLatitude={51.905070}
        searchLongitude={19.458834}
        googleApiKey={GOOGLE_API_KEY} 
        onSelect={place => this.setState({place})} 
    />

Keywords

FAQs

Package last updated on 10 Mar 2020

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