1

Actually I am using the FusedLocationApi for getting the user current location and after that i will add the marker on the Map and it's working fine.. Now i am adding a EditText on the MapFragment and the purpose of editText is if the user enter another location than my marker move to the New location...

So my Question is:

Is it Possible to find the places or Address through the FusedLocationApi because someOne Suggest me to use the Google Places Api

Dhruv Tyagi
  • 814
  • 1
  • 9
  • 28

3 Answers3

2

Use google place autocomplete for get location of search address on map. Place Autocomplete

Hitesh Gehlot
  • 1,307
  • 1
  • 15
  • 30
2

I think you want to search places in google places api, you can use PlaceAutocompleteFragment and get the location and search it through Latlong.

The problem you will face while just adding a Edittext is when the location is non recognizable by google maps api then it will show no place and keeps you thinking about the exact name instead PlaceAutocompleteFragment will help to guess you the exact places.

Implement - PlaceSelectionListener and add following code

PlaceAutocompleteFragment autocompleteFragment;
    PlaceSelectionListener ps;
autocompleteFragment = (PlaceAutocompleteFragment)
                getFragmentManager().findFragmentById(R.id.search1);

set listner -   autocompleteFragment.setOnPlaceSelectedListener(this);


public void onPlaceSelected(Place place) {
        if (m_map == null) {
            return;
        }
        g = place.getName().toString();

        final LatLng latLng = place.getLatLng();
        m_map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 21));


    }

XML-

<fragment
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
    android:id="@+id/search1"

    >
1

Is it Possible to find the places or Address through the FusedLocationApi because someOne Suggest me to use the Google Places Api

You have to use Google places Api to convert coordinates into addresses and vice-versa. FusedLocationApi is only helps to find gps coordinates of your phone.

Darish
  • 11,032
  • 5
  • 50
  • 70