Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Places: Bug: missing fields to request on place details #705

Closed
AndroidDeveloperLB opened this issue Dec 30, 2020 · 10 comments
Closed

Places: Bug: missing fields to request on place details #705

AndroidDeveloperLB opened this issue Dec 30, 2020 · 10 comments
Assignees
Labels
stale type: question Request for information or clarification. Not an issue.

Comments

@AndroidDeveloperLB
Copy link

Environment details

  1. Specify the API at the beginning of the title (for example, "Places: ...")
  2. OS type and version
    Android 11, but it doesn't matter
  3. Library version and other environment information
    implementation 'com.google.android.libraries.places:places:2.4.0'

Steps to reproduce

Try to get most updated information of a place details, after you got its basic ones via nearby-search.

Code example

  1. Suppose you use nearby-search:
        val placesClient = Places.createClient(context)
        val nearbySearchRequest = PlacesApi.nearbySearchQuery(GeoApiContext.Builder()
                .maxRetries(1)//.connectTimeout(2, TimeUnit.SECONDS).readTimeout(10, TimeUnit.SECONDS).writeTimeout(10, TimeUnit.SECONDS)
                .apiKey(apiKey).build(), latLng)
                .language(language)
        nearbySearchRequest.keyword(queryKeyword)
        nearbySearchRequest.type(placeType)
        nearbySearchRequest.rankby(RankBy.DISTANCE)
        nearbySearchRequest.setCallback(object : PendingResult.Callback<PlacesSearchResponse> {...})

From this you get an array of PlacesSearchResult:
https://googlemaps.github.io/google-maps-services-java/v0.2.4/javadoc/com/google/maps/model/PlacesSearchResult.html

  1. And some time later you want to get most updated information about some place from this list, as you have its place ID.
    Some of them are free:
    https://developers.google.com/places/web-service/usage-and-billing#basic-data
    And some aren't:
    https://developers.google.com/places/web-service/usage-and-billing#contact-data

I wanted to have updated information of : name, vicinity, location (LatLng), rating, phoneNumber, websiteUri, permanentlyClosed, and openingHours.

So this is what I tried (using this: https://developers.google.com/places/android-sdk/reference/com/google/android/libraries/places/api/net/PlacesClient#fetchPlace(com.google.android.libraries.places.api.net.FetchPlaceRequest) https://developers.google.com/places/android-sdk/place-details https://developers.google.com/places/web-service/details#PlaceDetailsResults ) :

        val placesClient = Places.createClient(context)
        val fieldsToGet = listOf(
                //basic fields: https://developers.google.com/places/web-service/usage-and-billing#basic-data
                Place.Field.NAME, Place.Field.ADDRESS, Place.Field.LAT_LNG, Place.Field.RATING,
                //extra, paid fields
                Place.Field.PHONE_NUMBER, Place.Field.WEBSITE_URI, Place.Field.OPENING_HOURS
        )
        placesClient.fetchPlace(FetchPlaceRequest.builder(googlePlace.id, fieldsToGet).build()).addOnCompleteListener { task -> ...}

The problem is, from this you get a different class called Place (here: https://developers.google.com/places/android-sdk/reference/com/google/android/libraries/places/api/model/Place ) , and it has different set of fields, and some seem missing:

  • name seems to exist in both.
  • vicinity exists on PlacesSearchResult, but I can't see it on Place. However, I can see address instead.
  • location exists on PlacesSearchResult using geometry?.location and I think for Place it's on latLng, but for some reason the type for each is different...
  • rating seems to exists on both, but on Place it's Double , and on PlacesSearchResult it's Float .
  • permanentlyClosed exists only on PlacesSearchResult

How could it be? Why can't I have the same fields as on PlacesSearchResult, but updated? How can I update the permanentlyClosed ? Am I correct about the fields that do seem to match ?
I've even noticed I can't set the language (useful in case the user has change the language) to query.

Am I doing things wrong?

@AndroidDeveloperLB AndroidDeveloperLB added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 30, 2020
@AndroidDeveloperLB AndroidDeveloperLB changed the title Places: Bug: missing fields to request on place details #130 Places: Bug: missing fields to request on place details Dec 30, 2020
@jpoehnelt jpoehnelt assigned arriolac and unassigned jpoehnelt Jan 28, 2021
@arriolac
Copy link
Member

arriolac commented Feb 10, 2021

You are correct that the objects are different and the reason you're seeing this difference is because you're using two different libraries: (1) the google-maps-services-java library (i.e. this library), which is not intended for consumption on Android, and (2) the Places SDK for Android. So technically no fields are missing and this is behaving as intended.

My recommendation is to remove your dependency on this library and stick with the Places SDK for Android. If you need to get nearby places, you can use the findCurrentPlace() API or the findAutocompletePredictions() API on Android. Our sample app also demonstrates how this can be used.

@arriolac arriolac added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 10, 2021
@AndroidDeveloperLB
Copy link
Author

@arriolac Why isn't there an official SDK from Google for them both? This causes fragmentation and confusion.
The Maps service exists for years...
How can I use only the part of Google that it offers, without the other part?

What do you mean about " findCurrentPlace() API or the findAutocompletePredictions() API " ? Instead of which parts?
I need to get nearby-places around some location, and then get from this result (of a list) details about each place.
The "findCurrentPlace" is only about getting current location. It doesn't help at all in this. We have Fused-location API already, so why have duplicate logic ? Is it the better way?
And how "findAutocompletePredictions" can help? It is meant for auto-completion, and it returns FindAutocompletePredictionsResponse, which has AutocompletePrediction in it:
https://developers.google.com/places/android-sdk/reference/com/google/android/libraries/places/api/model/AutocompletePrediction

Please explain what to do.

@arriolac
Copy link
Member

I need to get nearby-places around some location, and then get from this result (of a list) details about each place.

  1. findAutocompletePredictions() will allow you to find nearby places around some location. Take a look at this sample code.
  2. For each prediction, you can get the place details using fetchPlace()

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Feb 10, 2021

@arriolac Why is it called this way? Why "prediction" ? Why "autoComplete" ? It's very un-intuitive when the API is about nearby-search and getting details about places.

Are you sure that this API is as complete as the current repository?
And, shouldn't this repository get updated to match what's of Google (names of fields and their types) ?

@arriolac
Copy link
Member

arriolac commented Feb 10, 2021

The suggestion I had above is the closest replacement for nearby search, although I realize that it's not a true replacement for the functionality offered by the Places API. If you need that request on your app, and the suggestions I made above won't work, then setting up a proxy is the safest way to do so.

This table contains a list of data fields not included in the Places SDK for Android which are aligned with your observations: https://developers.google.com/places/web-service/place-data-fields

@AndroidDeveloperLB
Copy link
Author

AndroidDeveloperLB commented Feb 10, 2021

@arriolac OK so what's missing compared to what's here?
I used the fields I wrote on the snippet.

On the table, it shows that "Places SDK for Android" misses Address, URL, and Vicinity. Is it what I'm supposed to look at?
Or what I need already is enough there?

@stale
Copy link

stale bot commented Jun 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

@stale stale bot added the stale label Jun 11, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

Closing this. Please reopen if you believe it should be addressed. Thank you for your contribution.

@wangela
Copy link
Member

wangela commented Jan 30, 2023

The list of supported Place fields in Android is provided here. https://developers.google.com/maps/documentation/places/android-sdk/place-data-fields

@wangela wangela closed this as completed Jan 30, 2023
@AndroidDeveloperLB
Copy link
Author

@wangela Can you please update the code to have JavaDocs to point there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants