Решение 1:
Использование геокодера для обратного геокодирования.
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
try {
List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
StringBuilder sb = new StringBuilder();
if (addresses.size() > 0) {
Address address = addresses.get(0);
for (int i = 0; i < address.getMaxAddressLineIndex(); i++)
// get Place id
}catch(Exception e){
}
}
Решение 2: Получить идентификатор места
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY
Тогда вы можно фото из указанных c идентификаторов мест.
public void getPhotos(String placeId){
// Specify fields. Requests for photos must always have the PHOTO_METADATAS field.
List<Place.Field> fields = Arrays.asList(Place.Field.PHOTO_METADATAS);
// Get a Place object (this example uses fetchPlace(), but you can also use findCurrentPlace())
FetchPlaceRequest placeRequest = FetchPlaceRequest.newInstance(placeId, fields);
placesClient.fetchPlace(placeRequest).addOnSuccessListener((response) -> {
Place place = response.getPlace();
// Get the photo metadata.
PhotoMetadata photoMetadata = place.getPhotoMetadatas().get(0);
// Get the attribution text.
String attributions = photoMetadata.getAttributions();
// Create a FetchPhotoRequest.
FetchPhotoRequest photoRequest = FetchPhotoRequest.builder(photoMetadata)
.setMaxWidth(500) // Optional.
.setMaxHeight(300) // Optional.
.build();
placesClient.fetchPhoto(photoRequest).addOnSuccessListener((fetchPhotoResponse) -> {
Bitmap bitmap = fetchPhotoResponse.getBitmap();
imageView.setImageBitmap(bitmap);
}).addOnFailureListener((exception) -> {
if (exception instanceof ApiException) {
ApiException apiException = (ApiException) exception;
int statusCode = apiException.getStatusCode();
// Handle error with given status code.
Log.e(TAG, "Place not found: " + exception.getMessage());
}
});
});
}