Как отключить событие щелчка маркера TITLE? - PullRequest
0 голосов
/ 21 октября 2019

Я видел, как отключить событие щелчка маркером, но понятия не имею, как отключить событие щелчка маркера TITLE . Если я отключу событие щелчка маркером, заголовок останется активным. Как отключить его после первого клика?

Вот что я пробовал:

mMap.setOnInfoWindowClickListener(marker -> {
    //What to do?
});

1 Ответ

1 голос
/ 21 октября 2019

Попробуйте с этим кодом

Marker lastOpenned = null;

mMap.setOnMarkerClickListener(new OnMarkerClickListener() {
public boolean onMarkerClick(Marker marker) {
    // Check if there is an open info window
    if (lastOpenned != null) {
        // Close the info window
        lastOpenned.hideInfoWindow();

        // Is the marker the same marker that was already open
        if (lastOpenned.equals(marker)) {
            // Nullify the lastOpenned object
            lastOpenned = null;
            // Return so that the info window isn't openned again
            return true;
        } 
    }

    // Open the info window for the marker
    marker.showInfoWindow();
    // Re-assign the last openned such that we can close it later
    lastOpenned = marker;

    // Event was handled by our code do not launch default behaviour.
    return true;
}
});
...