gpt4 book ai didi

android - 使用集群时如何禁用android map 标记点击自动居中?

转载 作者:太空狗 更新时间:2023-10-29 15:45:39 24 4
gpt4 key购买 nike

我知道我可以避免在点击标记时使用相机居中:

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com