目前我正在尝试更改群集图标的颜色(默认为蓝色),但我似乎无法弄明白.我已经设置了我的集群管理器等,我可以看到图标本身,但它是蓝色的.我目前正在使用默认的Google设置(请参阅下面的代码)来设置我的地图.任何帮助,将不胜感激
谢谢,
雅各
public class MainActivity extends Activity {
GoogleMap map;
ClusterManager mClusterManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
map = mapFragment.getMap();
setUpClusterer();
}
private void setUpClusterer() {
// Declare a variable for the cluster manager.
// Position the map.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(51.503186,-0.126446),10));
// Initialize the manager with the context and the map.
// (Activity extends context,so we can pass 'this' in the constructor.)
mClusterManager = new ClusterManager
@H_502_13@
最佳答案@H_502_13@
正如Verma在评论中指出的那样,可以为您的集群实现完全可自定义的图标.如果您只想更改默认图标中的背景颜色,则此代码将执行此操作.
无论哪种方式,您都需要为ClusterManager设置渲染器:
mClusterManager.setRenderer(new CustomClusterRenderer(MainActivity.this,map,mClusterManager));
对于CustomClusterRenderer,您可以像这样扩展DefaultClusterRenderer:
public class CustomClusterRenderer extends DefaultClusterRenderer
@H_502_13@