Skip to content

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

@alan-leslie

Description

@alan-leslie

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions