Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places Api Android

I am searching for something where, I needs to pass my current location details(latitude and longitude) and retrieve the type of current place.

For example, If I am standing at ATM, and If I pass the latitude and longitude, Google should return me something like ATM as type.

For this purpose, I am using Google Places API

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
  Log.i(TAG, String.format("Place '%s' has likelihood: %g",
      placeLikelihood.getPlace().getName(),
      placeLikelihood.getLikelihood()));
}
likelyPlaces.release();
}
});

This is the main focus of code.

But Here It returns list of places Instead of one. I supposed that, Inside getCurrentPlace function of PlaceDetectionApi I should pass the radius instead of null. But I am not getting how to pass it. And my GoogleApiClient object is

 mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .addApi(Places.GEO_DATA_API)
                .addApi(Places.PLACE_DETECTION_API)
                .enableAutoManage(this, this)
                .build();

Thank you guys in advance.

like image 212
Jay Vyas Avatar asked Mar 07 '26 11:03

Jay Vyas


1 Answers

To get Atm List , Here is Google official link to get atm list of nearer location

Click on Place type Google will give you input parameter for place type, there you have to pass following parameter from the list . to know list of parameter click on this link

like image 62
J.D. Avatar answered Mar 09 '26 01:03

J.D.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!