【问题标题】:How to disable marker's TITLE click event?如何禁用标记的 TITLE 点击事件?
【发布时间】:2020-02-17 13:41:03
【问题描述】:

我已经看到如何禁用标记点击事件,但我不知道如何禁用标记TITLE点击事件。如果我禁用标记点击事件,标题仍然可以点击。第一次点击后如何禁用?

这是我尝试过的:

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

【问题讨论】:

    标签: android google-maps google-maps-api-3 google-maps-markers


    【解决方案1】:

    试试这个代码

    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;
    }
    });
    

    【讨论】:

    • 这是我在问题中指定的,如果即使在标记上禁用点击,标题仍然可以点击。
    • 你能通过编辑你的问题给我看那段代码吗?
    • 我不使用任何集群管理器。我有一张只有一个标记的地图。标题是打开的,在标题上单击一次后,我想删除单击事件。标记应该不再是可点击的了。
    • 让我试着让你回来。
    猜你喜欢
    • 2016-11-01
    • 2015-07-06
    • 2011-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多