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

In the finished code it does not matter what place marker you click on the same window is always shown #3

Open
alan-leslie opened this issue Jul 20, 2021 · 0 comments
Assignees

Comments

@alan-leslie
Copy link

URL of codelab
https://developers.google.com/codelabs/maps-platform/location-places-arcore-android#2

In which task and step of the codelab can this issue be found?
The problem occurs in the finished code

Describe the problem
It does not matter which marker you click on, the same window is shown.

Steps to reproduce?

  1. Download and open the 'solution' project
  2. Build and run (on either a real phone or an emulator)
  3. Once some markers appear, click on one. The window for the first place in the places list is shown.
  4. Click on another marker, the same window is shown.

Versions
_Android Studio version:4.2.2
_API version of the emulator:N/A

Additional information
I think that the reason for this is that the equals function in Place.kt is checking whether the 'id' is the same.
However the place 'id' in the places that you get from the PlacesService is always null (see screenshot of debug session)

places_ids

The data from the PlacesService does include a 'place_id'. For example:
"place_id" : "ChIJPw9ldbW1h0gRtro8aWp99fU",

If Place.kt is changed so that the id attribute is 'place_id' rather than 'id' and the equality check is changed to match, i.e.

data class Place(
val place_id: String,
val icon: String,
val name: String,
val geometry: Geometry
) {
override fun equals(other: Any?): Boolean {
if (other !is Place) {
return false
}
return this.place_id == other.place_id
}

override fun hashCode(): Int {
    return this.place_id.hashCode()
}

}

the correct window is shown when you click on the marker.

@arriolac arriolac self-assigned this Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants