Ad
Converting A PlaceID String To LatLng Object
Im trying to convert a placeId String which I stored on a database to LatLng coordinates, I got the id like so: place.getId()
from a place object and now when I retirived it from the server I would like to convert it back into coordinates or at least a Place object.
Thank you!
Ad
Answer
Declare the object as
GoogleApiClient mGoogleApiClient;
Then initialise it as
mGoogleApiClient =
new GoogleApiClient.Builder(...)
...
.build();
And pass it to the Places API's function.
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);
LatLng queriedLocation = myPlace.getLatLng();
Log.v("Latitude is", "" + queriedLocation.latitude);
Log.v("Longitude is", "" + queriedLocation.longitude);
}
places.release();
}
});
And retrieve the coordinates in the callback. (code copied from here)
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad