Сравнение маркеров карты Google

Я добавляю маркер на карту Google. И сохраните ссылку как поле моего класса.

 MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(position)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_aim))
                .anchor(0.5f, 0.5f)
                .draggable(false);
        mCurrentPositionMarker = mView.getGoogleMap().addMarker(markerOptions);

onMarkerClick (маркер-маркер) возвращает ссылку. Я добавил только один, поэтому (marker == mCurrentPositionMarker) должно быть истинным, но это ложно. Почему?

Можете ли вы добавить код, в котором вы получаете маркерную переменную?

Psypher 09.06.2018 16:25
0
1
446
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Из документов (выделено мной):

The Maps API allows you to listen and respond to marker events. To listen to these events, you must set the corresponding listener on the GoogleMap object to which the markers belong. When the event occurs on one of the markers on the map, the listener's callback will be invoked with the corresponding Marker object passed through as a parameter. To compare this Marker object with your own reference to a Marker object, you must use equals() and not ==.

Другие вопросы по теме