Reputation: 7557
In 'com.google.android.gms:play-services-location:9.4.0'
Unable to import import
com.google.android.gms.location.places.Places
Because of this Unable to build GoogleApiClient
and also unable to use Places.GeoDataApi.getPlaceById.
But in 'com.google.android.gms:play-services-location:8.4.0'
we can use it properly.
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId).setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (places.getStatus().isSuccess() && places.getCount() > 0) {
final com.google.android.gms.location.places.Place myPlace = places.get(0);
Log.i(TAG, "Place found: " + myPlace.getName());
map.addMarker(new MarkerOptions()
.position(myPlace.getLatLng())
.title(myPlace.getName().toString())
.snippet(myPlace.getAddress().toString()));
map.moveCamera(CameraUpdateFactory.newLatLng(myPlace.getLatLng()));
}
places.release();
}
});
Upvotes: 2
Views: 835
Reputation: 43322
In the latest versions of Google Play Services, they have broken it up even further, and now you need to include both location
and places
in order for the code in the question to compile:
dependencies {
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.android.gms:play-services-places:9.4.0'
//.......
}
Upvotes: 8