infoWindow's image not showing on first click, but it works on second click

前端 未结 3 1926
逝去的感伤
逝去的感伤 2020-12-21 14:49

My android using the Google map android API,InfoWindow\'s image not showing on first click, but it works on second click

I customize the infoWindow using

         


        
3条回答
  •  [愿得一人]
    2020-12-21 15:31

    I think Google has been listening and here's the solution that works for me. While setting up the cluster,

    getMap().setOnMapLoadedCallback(mOnMapLoaded);
    

    And once the map gets loaded, all the markers can be retreived from the clusterManager,

    private GoogleMap.OnMapLoadedCallback mOnMapLoaded = () -> {
        LogUtil.i(TAG, "Map has been loaded.");
        showInfoWindow();
    };
    
    private boolean showInfoWindow() {
        final WorkHeader selected = mWorkContainer.getSelectedHeader();
        Collection markers = mClusterManager.getMarkerCollection().getMarkers();
        for (Marker marker : markers) {
            if (marker.getTitle().contains(selected.siteName)) {
                if (marker.getTitle().contains(selected.siteAddress)) {
                    mClusterManager.onMarkerClick(marker);
                    return true;
                }
            }
        }
        return false;
    }
    

提交回复
热议问题