Android Maps Utils Clustering show InfoWindow

前端 未结 3 1613
天命终不由人
天命终不由人 2020-11-30 06:17

I am planning to use the google maps marker clustering available in the utils library, but the google example app only shows marker clusters without any infoWindow. I am won

3条回答
  •  庸人自扰
    2020-11-30 06:53

      @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.map);
    
            mClusterManager = new ClusterManager<>(this, mMap);
    
            mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
    
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186, -0.126446), 10));
            mMap.setOnCameraChangeListener(mClusterManager);
            mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
            /**
             * View for displaying marker popup, if null default framework view would be used
             */
            @Override
            public View getInfoWindow(Marker marker) {
                return null;
            }
    
            /**
             * For changing the content of infowindow
             * Called when showMarkerInfo method is called
             */
            @Override
            public View getInfoContents(Marker marker) {
                View v = getLayoutInflater().inflate(R.layout.view_to_inflate, null);      
                //code for initializing view part
                return v;
            }
        });
            readItems();
        }
    

提交回复
热议问题