I am making an android app, in which I will use the name of current location to search its details over wikipedia. for e.g. If I am in Madame Tussauds, First I ll get the current location coordinates then after reverse geocoding, it's info will be searched over wikipedia and displayed in my app.
I have my current location coordinates but the problem is when I reverse geocode the coordinates, I don't get the place name. for e.g. for coordinates 33.651826, 73.156593, when I reverse geocode, I get Park Road, Pakistan where as the name of the place is COMSATS Institute of Information Technology.
I get COMSATS Institute of Information Technology in Google Places API (Place Search) in Name node. So is there a way I can use Google Places API's name node for my current location name rather than any place search or other features?
Or is there any way I can get the place name using lat lon?
Define a GoogleApiClient object and then call this method
private void guessCurrentPlace() {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace( mGoogleApiClient, null );
result.setResultCallback( new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult( PlaceLikelihoodBuffer likelyPlaces ) {
PlaceLikelihood placeLikelihood = likelyPlaces.get( 0 );
String content = "";
if( placeLikelihood != null && placeLikelihood.getPlace() != null && !TextUtils.isEmpty( placeLikelihood.getPlace().getName() ) )
content = "Most likely place: " + placeLikelihood.getPlace().getName() + "\n";
if( placeLikelihood != null )
content += "Percent change of being there: " + (int) ( placeLikelihood.getLikelihood() * 100 ) + "%";
mTextView.setText( content );
likelyPlaces.release();
}
});
}
Reference: http://code.tutsplus.com/articles/google-play-services-using-the-places-api--cms-23715