Giter Club home page Giter Club logo

google-places-autocomplete-edittext's Introduction

Google Places AutoComplete EditText



A simple library that can connect your autocomplete edittext to Google's places api

        

Supporting Places AutoComplete EditText

Google Places AutoComplete EditText is an independent project with ongoing development and support made possible thanks to donations made by these awesome backers. If you'd like to join them, please consider:

How to integrate into your app?

Integrating the project is simple a refined all you need to do is follow the below steps

Step 1. Add the JitPack repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.mukeshsolanki:Google-Places-AutoComplete-EditText:<latest-version>'
}

How to use the library?

Okay seems like you integrated the library in your project but how do you use it? Well its really easy just add the following to your xml design

.....
 <AutoCompleteTextView
    android:id="@+id/autoCompleteEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
.....

To connect the AutoCompleteTextView to the places api create a PlaceApi object and attach it to the AutoCompleteTextView like-wise

 val placesApi = PlaceAPI.Builder().apiKey("YOUR_API_KEY").build(this@MainActivity)
 autoCompleteEditText.setAdapter(PlacesAutoCompleteAdapter(this, placesApi))

That's pretty much it and your all wrapped up. You have successfully connected the Places Api to the AutoCompleteTextView.

Getting details of place

To get the selected address simply set an ItemClickListener

autoCompleteEditText.onItemClickListener =
      AdapterView.OnItemClickListener { parent, _, position, _ ->
        val place = parent.getItemAtPosition(position) as Place
        autoCompleteEditText.setText(place.description)
      }

To get the details of the place selected you can set a listener to get the details

placesApi.fetchPlaceDetails("placeId", object : OnPlacesDetailsListener {
      override fun onError(errorMessage: String) {
        Toast.makeText(this@MainActivity, errorMessage, Toast.LENGTH_SHORT).show()
      }

      override fun onPlaceDetailsFetched(placeDetails: PlaceDetails) {
        //TODO do anything with placeDetails object
      }
    })

Places details you can get

Details Value
id get the record id (not to be confused with the place id)
name gets the name of the place
address gets a list of different address types like street number, route, locality, country, postal code
lat gets the latitude of the place
lng gets the longitude of the place
place id gets the id of the place
url gets the maps url of the place
utc offset gets the utc offset of the place
vicinity gets the vicinity of the place
compound plus code gets the expanded Google plus code
global plus code gets the shortened Google plus code

Author

Maintained by Mukesh Solanki

Contribution

GitHub contributors

License

MIT License

Copyright (c) 2019 Mukesh Solanki

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

google-places-autocomplete-edittext's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

google-places-autocomplete-edittext's Issues

Country filter

Is your feature request related to a problem? Please describe.
I cannot restrict the search to a specific country. I would like to restrict the search to India as other country results are of no use to me

Describe the solution you'd like
We have setCountry(...) in default AutocompleteSupportFragment so it would be nice to have that feature in this library as well

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

E/PlaceAPI: Cannot process JSON results

2020-08-14 00:29:28.268 23436-23501/com.ruzgar.rainbow E/PlaceAPI: Cannot process JSON results
org.json.JSONException: No value for plus_code
at org.json.JSONObject.get(JSONObject.java:399)
at org.json.JSONObject.getJSONObject(JSONObject.java:619)
at in.madapps.placesautocomplete.PlaceAPI.parseDetailsData(PlaceApi.kt:171)
at in.madapps.placesautocomplete.PlaceAPI.access$parseDetailsData(PlaceApi.kt:25)
at in.madapps.placesautocomplete.PlaceAPI$fetchPlaceDetails$1.run(PlaceApi.kt:70)
at java.lang.Thread.run(Thread.java:919)

No results

Hi! It just worked once. After showing results the first time, it didn't show any results anymore

Very heavy CPU use, slows down app downloading map tiles when visible

Subject of the issue

During the time that the widget is active, CPU use is very high

Steps to reproduce

Open widget on UI surface

Expected behaviour

The CPU use should be more inline with Google's widget

Actual behaviour

UI is very slow to respond, loading map tiles while this widget is displayed, tile loading runs at a snails pace. The same scenario, but using Google's widget is undetectable to UI response.

Java code?

Hi,

I was wondering if I can use your package with java?
I tried but got stuck at the PlaceAPI.builder part.

Is it supported and if so, could you provide the code?

Would be a big help, really looking to implement something like this instead of the usual AutoCompleteSupportFragment.

Thanks in advance.

Search radius

Thanks for your awesome library!

it would be awesome if you can add a parameter to put the cords of the user so when he search automatically he got hes near address by radius (e.g 500meters, 1km , etc..) instead of showing all the world's addresses.. ^^

Virsion

hello admin, please specify the latest version of the library
implementation 'com.github.mukeshsolanki:Google-Places-AutoComplete-EditText:'

PlacesAutoCompleteAdapter cannot be found

Added the library and created the PlaceApi object, but the adapter to be attached to the autocompletetextview cannot be found. I tried clearing cache and restarting but it doesnt work.

Latest version ?

Subject of the issue

Where do I find the version number for adding to the dependency?

What's the <latest-version> in build.gradle dependency?

I tried entering version of the app i.e. "1.0" as well as the latest version of Google places API. But neither did work. Would you mind telling me what should I enter in the @mukeshsolanki?
Thanks

dependencies {
        implementation 'com.github.mukeshsolanki:Google-Places-AutoComplete-EditText:**<latest-version>**'
}

Places SDK

what Places sdk version are you using (The Google Play Services version or new)? Asking as " The Google Play Services version of the Places SDK for Android (in Google Play Services 16.0.0) is deprecated as of January 29, 2019, and will be turned off on July 29, 2019 "

Session Tokens

Subject of the issue

Enable the users to add session tokens

Steps to reproduce

N/A

Expected behaviour

The users should be able to use session tokens

Actual behaviour

Right now this is not happening

User can dismiss ...

When the dropDown menu appears, the user can dismiss it with a touch outside and the api request will not give results , is there any way to check if the api request was made or not ?

Powered by Google

Subject of the issue

Add Powered by Google Footer

Steps to reproduce

N/A

Expected behaviour

The footer should be shown as per googles documentation

Actual behaviour

The footer is not being shown at the moment

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.