@@ -736,7 +736,10 @@ public void remove(Marker m) {
736
736
}
737
737
738
738
/**
739
- * Called before the marker for a ClusterItem is added to the map.
739
+ * Called before the marker for a ClusterItem is added to the map. The default implementation
740
+ * sets the marker and snippet text based on the respective item text if they are both
741
+ * available, otherwise it will set the title if available, and if not it will set the marker
742
+ * title to the item snippet text if that is available.
740
743
*
741
744
* The first time {@link ClusterManager#cluster()} is invoked on a set of items
742
745
* {@link #onBeforeClusterItemRendered(ClusterItem, MarkerOptions)} will be called and
@@ -749,6 +752,14 @@ public void remove(Marker m) {
749
752
* @param markerOptions the markerOptions representing the provided item
750
753
*/
751
754
protected void onBeforeClusterItemRendered (T item , MarkerOptions markerOptions ) {
755
+ if (item .getTitle () != null && item .getSnippet () != null ) {
756
+ markerOptions .title (item .getTitle ());
757
+ markerOptions .snippet (item .getSnippet ());
758
+ } else if (item .getTitle () != null ) {
759
+ markerOptions .title (item .getTitle ());
760
+ } else if (item .getSnippet () != null ) {
761
+ markerOptions .title (item .getSnippet ());
762
+ }
752
763
}
753
764
754
765
/**
@@ -952,14 +963,6 @@ private void perform(MarkerModifier markerModifier) {
952
963
} else {
953
964
markerOptions .position (item .getPosition ());
954
965
}
955
- if (!(item .getTitle () == null ) && !(item .getSnippet () == null )) {
956
- markerOptions .title (item .getTitle ());
957
- markerOptions .snippet (item .getSnippet ());
958
- } else if (!(item .getSnippet () == null )) {
959
- markerOptions .title (item .getSnippet ());
960
- } else if (!(item .getTitle () == null )) {
961
- markerOptions .title (item .getTitle ());
962
- }
963
966
onBeforeClusterItemRendered (item , markerOptions );
964
967
marker = mClusterManager .getMarkerCollection ().addMarker (markerOptions );
965
968
markerWithPosition = new MarkerWithPosition (marker );
0 commit comments