Giter Site home page Giter Site logo

houseofstylist / react-native-google-places-autocomplete Goto Github PK

View Code? Open in Web Editor NEW

This project forked from faridsafi/react-native-google-places-autocomplete

0.0 1.0 0.0 648 KB

Customizable Google Places autocomplete component for iOS and Android React-Native apps

License: MIT License

JavaScript 74.17% Java 8.14% Objective-C 17.69%

react-native-google-places-autocomplete's Introduction

react-native-google-places-autocomplete

Customizable Google Places autocomplete component for iOS and Android React-Native apps

Changelog

  • 1.1.10 : Update to work with react-native > 0.24
  • 1.1.9 : Added setAddressText method
  • 1.1.8 : Ability to set address from outside of component
  • 1.1.7 : Support for RN v0.26
  • 1.1.6 : currentLocationAPI renamed to nearbyPlacesAPI, added predefinedPlacesAlwaysVisible prop
  • 1.1.4 : Added 'Current Location' and predefinied places features - PRs @kevinstumpf @VonD
  • 1.1.3 : Keyboard is now dismissed by default when scrolling to be more usable with small height devices (eg: iPhone 4) + Props are now passed to the results ListView

Example

var {GooglePlacesAutocomplete} = require('react-native-google-places-autocomplete');

const homePlace = {description: 'Home', geometry: { location: { lat: 48.8152937, lng: 2.4597668 } }};
const workPlace = {description: 'Work', geometry: { location: { lat: 48.8496818, lng: 2.2940881 } }};

var Example = React.createClass({
  render() {
    return (
      <GooglePlacesAutocomplete
        placeholder='Search'
        minLength={2} // minimum length of text to search
        autoFocus={false}
        fetchDetails={true}
        onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
          console.log(data);
          console.log(details);
        }}
        getDefaultValue={() => {
          return ''; // text input default value
        }}
        query={{
          // available options: https://developers.google.com/places/web-service/autocomplete
          key: 'YOUR API KEY',
          language: 'en', // language of the results
          types: '(cities)', // default: 'geocode'
        }}
        styles={{
          description: {
            fontWeight: 'bold',
          },
          predefinedPlacesDescription: {
            color: '#1faadb',
          },
        }}

        currentLocation={true} // Will add a 'Current location' button at the top of the predefined places list
        currentLocationLabel="Current location"
        nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
        GoogleReverseGeocodingQuery={{
          // available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
        }}
        GooglePlacesSearchQuery={{
          // available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
          rankby: 'distance',
          types: 'food',
        }}


        filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities

        predefinedPlaces={[homePlace, workPlace]}
      />
    );
  }
});

Installation

  1. npm install react-native-google-places-autocomplete --save
  2. Get your Google Places API keys and enable "Google Places API Web Service" (NOT Android or iOS) in the console.
  3. Enable "Google Maps Geocoding API" if you want to use GoogleReverseGeocoding for Current Location

Features

  • Places autocompletion
  • iOS and Android compatibility
  • Places details fetching + ActivityIndicatorIOS/ProgressBarAndroid loaders
  • Customizable using the styles parameter
  • XHR cancellations when typing fast
  • Google Places terms compliant
  • Current location
  • Predefined places

License

MIT

Authors

react-native-google-places-autocomplete's People

Contributors

codenamev avatar faridsafi avatar gedzis avatar halilb avatar hartmamt avatar jonnybgod avatar kanerogers avatar santilorenzo avatar vond avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.