Search in sources :

Example 1 with PlaceAutocompleteFragment

use of com.google.android.gms.location.places.ui.PlaceAutocompleteFragment 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 PlaceAutocompleteFragment

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

the class FileComplaintFragment method onDestroyView.

@Override
public void onDestroyView() {
    super.onDestroyView();
    android.app.FragmentManager fragmentManager = getActivity().getFragmentManager();
    PlaceAutocompleteFragment fragment = (PlaceAutocompleteFragment) fragmentManager.findFragmentById(R.id.place_autocomplete_fragment);
    android.app.FragmentTransaction ft = fragmentManager.beginTransaction();
    ft.remove(fragment);
    ft.commit();
}
Also used : PlaceAutocompleteFragment(com.google.android.gms.location.places.ui.PlaceAutocompleteFragment)

Aggregations

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