Giter VIP home page Giter VIP logo

material-ui-autocomplete-google-places's Introduction

material-ui-autocomplete-google-places

React component that uses Google Places API AutocompleteService, Google Maps Geocoder, and Material-UI AutoComplete to replicate Google Places Autocomplete search dropdown in Material-UI. Returns latitude and longitude from selected item.

Useful Links:

To get started:

Include script tag in html file:

<head>
  <script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>
</head>

Install package:

$ npm install material-ui-autocomplete-google-places

Basic Use Case:

import GooglePlaceAutocomplete from 'material-ui-autocomplete-google-places';

class App extends React.Component {
  // Results from clicking on location
  getCoords(lat, lng){
    console.log(lat, lng);
  }

  render() {
    return (
      <MuiThemeProvider muiTheme={getMuiTheme()}>
        <GooglePlaceAutocomplete
        	// Function to return lat and lng
        	results={this.getCoords}
        />
      </MuiThemeProvider>
    );
  }
}

Optional Parameters for Google Places AutocompletionRequest object:

<GooglePlaceAutocomplete
  // Function to return lat and lng
  results={this.getCoords}

  // AutocompletionRequest object specification
  componentRestrictions={{country: 'au'}}
  types={['establishment']}
/>

Available properties for GooglePlaceAutocomplete:

  • anchorOrigin
  • animated - default: true
  • animation
  • errorStyle
  • errorText
  • floatingLabelText
  • fullWidth - default: true
  • hintText - default: ' '
  • listStyle
  • maxSearchResults
  • menuCloseDelay
  • menuStyle
  • onClose
  • open - default: false
  • style
  • targetOrigin
  • textFieldStyle

Edit dropdown menu via:

  • menuItemStyle

Defaults for menuItemStyle

style={this.props.menuItemStyle || {
  fontSize: 13,
  display: 'block',
  paddingRight: 20,
  overflow: 'hidden',
 }

See repo for more details.

License

This package is licensed under the terms of MIT License. See the LICENSE file for further information.

material-ui-autocomplete-google-places's People

Contributors

sautumn avatar archcorsair avatar bmkrocks1 avatar katbusch avatar

Watchers

James Cloos 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.