G
G
gape2016-02-01 23:10:34
Android
gape, 2016-02-01 23:10:34

How can I get a photo of a city by name or its coordinates?

Tried using google api, but it doesn't return photo reference for cities, it returns only for places (restaurants, museums, etc.). I tried using flickr and panoramio, but random photos are returned according to geodata, not the best ones. How to find photos that are on google maps
3a1336d5219745b9bf770ded9387fc4e.PNG
or that are given in the search
d7f84c9bd8eb4d4cb92a2d5a5d4d8cd9.PNG

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
razer89, 2016-02-02
@razer89

Do not reinvent the wheel, and do not try to parse something - this is a disastrous business. Use the API
As part of Android development, I would still recommend that you use the official API. I don't quite understand what you don't like about it. Pay attention to the following code:
1. Initialize ApiClient:

GoogleApiClient googleApiClient = new GoogleApiClient.Builder(service).addApi(Places.GEO_DATA_API).build();
googleApiClient.connect();

2. Initialize the filter by cities:
AutocompleteFilter filter = new AutocompleteFilter.Builder()
                .setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES)
                .build();

3. We get the list (in my case it is AutocompletePrediction, you can go in a more convenient way for you):
PendingResult<AutocompletePredictionBuffer> result = Places.GeoDataApi
                .getAutocompletePredictions(googleApiClient, externalQuery, null, filter);
AutocompletePredictionBuffer autocompletePredictions = result.await(60, TimeUnit.SECONDS);
ArrayList<AutocompletePrediction> predictions = DataBufferUtils.freezeAndClose(autocompletePredictions);
autocompletePredictions.release();

Well, actually we get a list of photos:
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi.getPlaceById(googleApiClient, prediction.getPlaceId());
Places.GeoDataApi.getPlacePhotos(googleApiClient, prediction.getPlaceId());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question