Skip to content

Commit d2658e3

Browse files
Fix: #1424 - Added zIndex to markerOptions in onBeforeClusterRendered and onBeforeClusterItemRendered
1 parent 67b4aca commit d2658e3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

library/src/main/java/com/google/maps/android/clustering/view/DefaultClusterRenderer.java

+11
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.util.ArrayList;
6060
import java.util.Collections;
6161
import java.util.HashMap;
62+
import java.util.Iterator;
6263
import java.util.LinkedList;
6364
import java.util.List;
6465
import java.util.Map;
@@ -836,6 +837,9 @@ protected void onBeforeClusterItemRendered(@NonNull T item, @NonNull MarkerOptio
836837
} else if (item.getSnippet() != null) {
837838
markerOptions.title(item.getSnippet());
838839
}
840+
if (item.getZIndex() != null) {
841+
markerOptions.zIndex(item.getZIndex());
842+
}
839843
}
840844

841845
/**
@@ -906,6 +910,13 @@ protected void onClusterItemUpdated(@NonNull T item, @NonNull Marker marker) {
906910
protected void onBeforeClusterRendered(@NonNull Cluster<T> cluster, @NonNull MarkerOptions markerOptions) {
907911
// TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often)
908912
markerOptions.icon(getDescriptorForCluster(cluster));
913+
Iterator<T> iterator = cluster.getItems().iterator();
914+
if (iterator.hasNext()) {
915+
Float zIndex = iterator.next().getZIndex();
916+
if (zIndex != null) {
917+
markerOptions.zIndex(zIndex);
918+
}
919+
}
909920
}
910921

911922
/**

0 commit comments

Comments
 (0)