简体   繁体   English

群集上方的Android Google Maps Utils群集管理器标记

[英]Android Google Maps Utils Cluster Manager marker above clusters

I'm using Google Maps Utils library for clustering markers. 我正在使用Google Maps Utils库进行聚类标记。 I'm adding most of markers to cluster manager. 我将大多数标记添加到集群管理器。 The rest I'm adding to map (I don't want them to be clustered with others). 我要添加到地图上的其余内容(我不希望它们与其他群集在一起)。 My problem is that clusters are drawn above standard markers and cover them. 我的问题是,群集在标准标记上方绘制并覆盖它们。 Is there any way to change drawing order ie first clusters and markers above them? 有什么方法可以更改绘图顺序,即它们上方的第一个簇和标记吗?

Here's part of my code: 这是我的代码的一部分:

    clusterManager = new ClusterManager<>(getActivity(), map);
    clusterManager.setRenderer(new MyObjectRenderer(getActivity(), map, clusterManager));
    clusterManager.setOnClusterItemClickListener(this);
    map.setOnMarkerClickListener(clusterManager);

    for (MyObject object : list) {
        clusterManager.addItem(object);
    }

    clusterManager.cluster();

    for (MyOtherObject object : otherList) {
        map.addMarker(new MarkerOptions().position(object.getLatLng()).title(object.getName()));
    }

I had a similar scenario: I was adding several locations to my ClusterManager and I needed a marker with the user position on top of all the other markers. 我有一个类似的场景:我在ClusterManager中添加了几个位置,并且需要一个标记,其用户位置应位于所有其他标记的顶部。

This worked for me: 这为我工作:

Add user marker to map with zIndex to 1000 to ensure that it will be placed on top. 添加用户标记以将zIndex映射到1000,以确保将其放置在顶部。

MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(userLocation.getLatitude(), userLocation.getLongitude())).zIndex(1000);
map.addMarker(markerOptions);

Add markers to cluster manager. 将标记添加到集群管理器。

for (MyObject object : objects) {
     mClusterManager.addItem(object);   
}
mClusterManager.cluster();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM