作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我知道我可以避免在点击标记时使用相机居中:
mGoogleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
marker.showInfoWindow();
return true;
}
});
但是,我遇到的问题是现在我想使用聚类,当然我想在标记(实际上是项目或聚类)被录音时看到信息窗口。但我不知道在这些情况下如何调用 showInfoWindow 之类的东西。在此代码中,如果我返回 false,我会看到信息窗口,但 map 居中。如果我返回 true,则 map 不会居中但不会显示信息窗口:
mClusterManager.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<HotspotMarker>() {
@Override
public boolean onClusterItemClick(HotspotMarker item) {
Log.e(LOG_TAG, "---OnClusterItemClick");
return false;
}
});
mClusterManager.setOnClusterItemInfoWindowClickListener(new ClusterManager.OnClusterItemInfoWindowClickListener<HotspotMarker>() {
@Override
public void onClusterItemInfoWindowClick(HotspotMarker hotspotMarker) {
Log.e(LOG_TAG, "---onClusterItemInfoWindowClick");
HotspotDetailActivity.hotspot = hotspotMarker.getHotspot();
Intent intent = new Intent(getActivity(), HotspotDetailActivity.class);
startActivity(intent);
}
});
mClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener<HotspotMarker>() {
@Override
public boolean onClusterClick(Cluster<HotspotMarker> cluster) {
Log.e(LOG_TAG, "---OnClusterClickListener");
return false;
}
});
mClusterManager.setOnClusterInfoWindowClickListener(new ClusterManager.OnClusterInfoWindowClickListener<HotspotMarker>() {
@Override
public void onClusterInfoWindowClick(Cluster<HotspotMarker> cluster) {
Log.e(LOG_TAG, "---onClusterInfoWindowClick");
ArrayList<HotspotMarker> markers = new ArrayList<>(cluster.getItems());
ClusterListActivity.markers = markers;
Intent detailHotspot = new Intent(getActivity(), ClusterListActivity.class);
startActivity(detailHotspot);
}
});
当我使用聚类并同时显示信息窗口时,您是否知道如何避免将 map 居中?提前致谢。
编辑:使用@skywall 的建议,我发现了使用自定义渲染器的更好方法:
mClusterManager.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<HotspotMarker>() {
@Override
public boolean onClusterItemClick(HotspotMarker item) {
Marker marker=mClusteringRenderer.getMarker(item);
marker.showInfoWindow();
return true;
}
});
mClusterManager.setOnClusterItemInfoWindowClickListener(new ClusterManager.OnClusterItemInfoWindowClickListener<HotspotMarker>() {
@Override
public void onClusterItemInfoWindowClick(HotspotMarker hotspotMarker) {
HotspotDetailActivity.hotspot = hotspotMarker.getHotspot();
Intent intent = new Intent(getActivity(), HotspotDetailActivity.class);
startActivity(intent);
}
});
mClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener<HotspotMarker>() {
@Override
public boolean onClusterClick(Cluster<HotspotMarker> cluster) {
Marker marker=mClusteringRenderer.getMarker(cluster);
marker.showInfoWindow();
return true;
}
});
mClusterManager.setOnClusterInfoWindowClickListener(new ClusterManager.OnClusterInfoWindowClickListener<HotspotMarker>() {
@Override
public void onClusterInfoWindowClick(Cluster<HotspotMarker> cluster) {
ArrayList<HotspotMarker> markers = new ArrayList<>(cluster.getItems());
ClusterListActivity.markers = markers;
Intent detailHotspot = new Intent(getActivity(), ClusterListActivity.class);
startActivity(detailHotspot);
}
});
最佳答案
为
setOnClusterItemClickListener
返回 true
关于android - 使用集群时如何禁用android map 标记点击自动居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31470657/
我是一名优秀的程序员,十分优秀!