Search in sources :

Example 1 with AutocompleteFilter

use of com.google.android.gms.location.places.AutocompleteFilter in project IITB-App by wncc.

the class FileComplaintFragment method autoLocation.

private void autoLocation() {
    final PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getActivity().getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
    AutocompleteFilter typeFilter = new AutocompleteFilter.Builder().setCountry("IN").build();
    autocompleteFragment.setFilter(typeFilter);
    autocompleteFragment.setHint("Enter Location");
    autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {

        @Override
        public void onPlaceSelected(com.google.android.gms.location.places.Place place) {
            Location = place.getLatLng();
            String Name = place.getName().toString();
            Address = place.getAddress().toString();
            // on selecting the place will automatically shows the Details on the map.
            updateMap(Location, Name, Address, cursor);
            cursor++;
        }

        @Override
        public void onError(Status status) {
            Log.i(TAG, "An error occurred: " + status);
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) AutocompleteFilter(com.google.android.gms.location.places.AutocompleteFilter) PlaceSelectionListener(com.google.android.gms.location.places.ui.PlaceSelectionListener) PlaceAutocompleteFragment(com.google.android.gms.location.places.ui.PlaceAutocompleteFragment)

Example 2 with AutocompleteFilter

use of com.google.android.gms.location.places.AutocompleteFilter in project UniPool by divya21raj.

the class NewEntryActivity method showPlaceAutocomplete.

private void showPlaceAutocomplete(int i) {
    try {
        AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder().setTypeFilter(Place.TYPE_COUNTRY).setCountry("IN").build();
        Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY).setFilter(autocompleteFilter).build(this);
        startActivityForResult(intent, i);
    } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
        Toast.makeText(this, "Google Play Service Error!", Toast.LENGTH_SHORT).show();
    }
}
Also used : AutocompleteFilter(com.google.android.gms.location.places.AutocompleteFilter) Intent(android.content.Intent) GooglePlayServicesRepairableException(com.google.android.gms.common.GooglePlayServicesRepairableException) GooglePlayServicesNotAvailableException(com.google.android.gms.common.GooglePlayServicesNotAvailableException)

Aggregations

AutocompleteFilter (com.google.android.gms.location.places.AutocompleteFilter)2 Intent (android.content.Intent)1 GooglePlayServicesNotAvailableException (com.google.android.gms.common.GooglePlayServicesNotAvailableException)1 GooglePlayServicesRepairableException (com.google.android.gms.common.GooglePlayServicesRepairableException)1 Status (com.google.android.gms.common.api.Status)1 PlaceAutocompleteFragment (com.google.android.gms.location.places.ui.PlaceAutocompleteFragment)1 PlaceSelectionListener (com.google.android.gms.location.places.ui.PlaceSelectionListener)1