我正在开发基于地图的应用程序,我使用集群来安排标记。它工作正常。现在,我需要在点击标记时显示一条消息。对此有什么解决方案吗?
mMap.setOnCameraIdleListener( mClusterManager);
mMap.setOnMarkerClickListener(mClusterManager);
我使用了setOnMarkerClickListener,但我不知道点击事件会在哪里获得
答案 0 :(得分:2)
我这样做了一个解决方案..
mClusterManager = new ClusterManager<MyItem>(getActivity(), mMap, new MarkerManager(mMap){
@Override
public boolean onMarkerClick(Marker marker) {
//here will get the clicked marker
return super.onMarkerClick(marker);
}
});
mClusterManager.setRenderer(new CusterCustomMarkerRenderer( context , mMap, mClusterManager, HomeFragment.this));
mClusterManager.setOnClusterClickListener(this);
mMap.setOnMarkerClickListener(mClusterManager);
答案 1 :(得分:0)
看起来您已经完成了第一步,以便在使用标记群集时检测标记上的点击事件。接下来,在致电.setOnMarkerClickListener(mClusterManager)
后,您需要通过实施clusterItemClickListener()
接口注册ClusterManager.OnClusterItemClickListener<T>
。试试这个:
public class YourActivity extends AppCompatActivity implements
ClusterManager.OnClusterItemClickListener<YourClusterItem> {
....
mMap.setOnCameraIdleListener( mClusterManager);
mMap.setOnMarkerClickListener(mClusterManager);
//set the onClusterItemClickListener
mClusterManager.setOnClusterItemClickListener(this);
//implement the onClusterItemClick interface
@Override
public boolean onClusterItemClick(YourClusterItem clusterItem){
//handle click event
return true;
}
}