use of com.google.android.libraries.places.api.net.FetchPlaceRequest in project react-native-google-places by tolu360.
the class RNGooglePlacesModule method lookUpPlaceByID.
@ReactMethod
public void lookUpPlaceByID(String placeID, ReadableArray fields, final Promise promise) {
this.pendingPromise = promise;
if (!Places.isInitialized()) {
promise.reject("E_API_KEY_ERROR", new Error("No API key defined in gradle.properties or errors initializing Places"));
return;
}
List<Place.Field> selectedFields = getPlaceFields(fields.toArrayList(), false);
FetchPlaceRequest request = FetchPlaceRequest.builder(placeID, selectedFields).build();
placesClient.fetchPlace(request).addOnSuccessListener((response) -> {
Place place = response.getPlace();
WritableMap map = propertiesMapForPlace(place, selectedFields);
promise.resolve(map);
}).addOnFailureListener((exception) -> {
promise.reject("E_PLACE_DETAILS_ERROR", new Error(exception.getMessage()));
});
}
Aggregations