Voora Tarun
Voora Tarun

Reputation: 1226

Getting Place data from gedodata API

I have place Id, I am using geodata api to get place details. how to build googleApi client for that. I did like this.

mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Places.GEO_DATA_API).build()

IN Onconnected method, I did following

public void onConnected(Bundle bundle) {
        Toast.makeText(this,"connected",Toast.LENGTH_LONG).show();
        Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
                .setResultCallback(new ResultCallback<PlaceBuffer>() {
                    @Override
                    public void onResult(PlaceBuffer places) {
                        if (places.getStatus().isSuccess()) {
                            final Place myPlace = places.get(0);
                            Log.i("mytag", "Place found: " + myPlace.getName() + myPlace.getLatLng().toString());
                        }
                        places.release();
                    }
                });

    }

I am not getting the result, how to build googleApi client to geodata Api ?

I used server key in manifest file

Upvotes: 1

Views: 86

Answers (1)

Anoop M Maddasseri
Anoop M Maddasseri

Reputation: 10559

You can follow the official document of google for getting place details by id/get user current place/place picker widget etc.

Setting up google api client link.

Follow this blog too for simple explanations.

And you can also get it by using the API https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJrTLr-GyuEmsRBfy61i59si0&key=YOUR_API_KEY without configuring google play service.

visit for more.

Upvotes: 1

Related Questions