【问题标题】:Android Google Maps V2 Cluster hide infoWindowAndroid Google Maps V2 Cluster 隐藏 infoWindow
【发布时间】:2014-10-01 15:38:41
【问题描述】:

在 Android 项目中,我使用 Google Maps Android API 实用程序库来使用集群解决方案。

在每个单个标记或聚类标记上,一个信息窗口会在触摸所选标记时打开。然后在 infoWindow 上触摸我使用这些事件:

...
mClusterManager.setOnClusterInfoWindowClickListener(this);
mClusterManager.setOnClusterItemInfoWindowClickListener(this);
...

和:

@Override
public void onClusterInfoWindowClick(Cluster<JobItem> cluster) {
    // Here I go to a new fragment A, list of items.

}

@Override
public void onClusterItemInfoWindowClick(JobItem item) {
    // Here I go to a new fragment B, item's details

}

当我回到地图(片段 A 或 B 中的 popBackStack)时,infoWindow 总是打开的。当我转到片段 A 或 B 时,我想以编程方式隐藏它们。 我发现可以从标记对象调用方法 hideInfoWindow() 但在这两个事件中标记没有通过参数传递。

知道如何隐藏 infoWindow 吗?

【问题讨论】:

    标签: android google-maps hide cluster-computing infowindow


    【解决方案1】:

    我找到了一个适合我的解决方案,将此代码添加到片段的 onResume 中,它将关闭所有打开的 InfoWindow。

    java.util.Collection<Marker> markerCollection = mClusterManager.getMarkerCollection().getMarkers();
    for(Marker m : markerCollection){
        if(m.isInfoWindowShown())
        m.hideInfoWindow();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 2013-03-31
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多