Git Product home page Git Product logo

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

Current Status of Project

Sadly this project has been neglected as our jobs have taken all of our attention. Sorry ๐Ÿ˜ž

I've recently fixed breaking issues for Material UI 0.17.0, the package currently only works with this legacy version.

The Good News ๐ŸŽ‰

Some free time has come up and our goal is to do a complete rewrite with support for the latest Material UI (3.8.x as of this writing)

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

archcorsair avatar bmkrocks1 avatar katbusch avatar sautumn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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

Text display not updating

When I tried to use this exactly as in the example with material-ui version 17.4, the search box is empty even when you type in it. I debugged a little and saw that when updateInput is being called, the first parameter is the react component, so the the this isn't being bound correctly. The second parameter is actually the text that was typed.

Remove injectTapEventPlugin() from the library code

It crashes the app

Error: injectTapEventPlugin(): Can only be called once per application lifecycle.

It is recommended to call injectTapEventPlugin() just before you call ReactDOM.render(). If you are using an external library which calls injectTapEventPlugin() itself, please contact the maintainer as it shouldn't be called in library code and should be injected by the application.

"import GooglePlaceAutocomplete" itself throws error

Console shows in red "Uncaught TypeError: Cannot read property 'object' of undefined".
Is it intended to work with React 16?
CLI shows the whole bunch of warnings. Three of them require previous versions of React, ReactDOM, material-ui and the next one requires react-tap-event-plugin.

API key requested

Hi,
I'm trying to use the library but every time I focus on the text field, a console error is displayed:

proxyConsole.js:56 This service requires an API key.  For more information on authentication and Google Maps Javascript API services please see: https://developers.google.com/maps/documentation/javascript/get-api-key

I have not found a way to solve it. Where do I need to put the API key?

thanks.

Cross-browser

DISCLAIMER: I am not entirely sure if this is a material-ui autocomplete issue or a material-ui-autocomplete-google-places issue.

The plugin works on google chrome on the laptop but nothing happens on Safari, chrome on mobile or safari on mobile.

Any suggestions?

Change import type from material-ui

At the moment the import statement from material-ui is:
import { AutoComplete, MenuItem } from 'material-ui';

As far as I understand it, this imports all of material-ui - rather than just the components needed. (see the first answer here: https://stackoverflow.com/questions/41333561/reactjs-material-ui-app-is-whooping-917kb-in-production-build-what-do-i-do-to-d)

I think this should this be changed to:

import AutoComplete from 'material-ui/AutoComplete';
import MenuItem from 'material-ui/MenuItem';

React warning

Accessing PropTypes via the main React package is deprecated, and will be removed in React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see https://fb.me/prop-types-docs

Is there any plan to update this? I see there is a pending pull request

New release?

Hey!

Nice lib!!

However, currently I'm blocked by PropTypes not being available - but that seems to have been fixed already in master! Any chance you'd be interested in releasing this lib? Thanks!

Unknown prop `disableFocusRipple` on <div> tag

As soon as I type a into the GooglePlaceAutocomplete component I see the following message in the console: Warning: Unknown prop disableFocusRipple on

tag. Remove this prop from the element...

filling in field on load

Hey,

I want to automatically fill in the text field when the component mounts. I am getting back the string from another plugin of the user current location and now I want to insert that text into the GooglePlaceAutocomplete component.

I tried setting searchText but nothing. Any suggestions?

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.