Reputation: 1450
How can I get latitude & longitude from Google Place API of android? My code looks like below..
AutocompleteFilter mAutocompleteFilter = new AutocompleteFilter.Builder().setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES).build();
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi
.getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
mBounds, mAutocompleteFilter);
I also facing trouble getting results more than 5 results. I'm using this link for the references. Any help would be grateful.
Upvotes: 1
Views: 3336
Reputation: 4845
You should do something like that:
Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer p) {
if (p.getStatus().isSuccess()) {
final Place mPlace = p.get(0);
LatLng qLoc = mPlace.getLatLng();
//you can use lat with qLoc.latitude;
//and long with qLoc.longitude;
}
p.release();
}
});
Upvotes: 4