FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: adding cluster size as title for Markers by kikoso · Pull Request #1542 · googlemaps/android-maps-utils · GitHub

Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
import com.google.maps.android.ui.IconGenerator;
import com.google.maps.android.utils.demo.model.Person;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;

/**
Expand Down Expand Up @@ -109,12 +111,14 @@ protected void onBeforeClusterRendered(@NonNull Cluster<Person> cluster, @NonNul
// Draw multiple people.
// Note: this method runs on the UI thread. Don't spend too much time in here (like in this example).
markerOptions.icon(getClusterIcon(cluster));
markerOptions.title(getLocalizedNumber(cluster.getSize()));
}

@Override
protected void onClusterUpdated(@NonNull Cluster<Person> cluster, Marker marker) {
// Same implementation as onBeforeClusterRendered() (to update cached markers)
marker.setIcon(getClusterIcon(cluster));
marker.setTitle(getLocalizedNumber(cluster.getSize()));
}

/**
Expand Down Expand Up @@ -250,4 +254,9 @@ private LatLng position() {
private double random(double min, double max) {
return mRandom.nextDouble() * (max - min) + min;
}

private String getLocalizedNumber(int number) {
NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault());
return numberFormat.format(number);
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@
import com.google.maps.android.ui.IconGenerator;
import com.google.maps.android.ui.SquareTextView;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
Expand Down Expand Up @@ -906,6 +908,7 @@ protected void onClusterItemUpdated(@NonNull T item, @NonNull Marker marker) {
protected void onBeforeClusterRendered(@NonNull Cluster<T> cluster, @NonNull MarkerOptions markerOptions) {
// TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often)
markerOptions.icon(getDescriptorForCluster(cluster));
markerOptions.title(getLocalizedNumber(cluster.getSize()));
}

/**
Expand Down Expand Up @@ -960,6 +963,7 @@ protected void onClusterRendered(@NonNull Cluster<T> cluster, @NonNull Marker ma
protected void onClusterUpdated(@NonNull Cluster<T> cluster, @NonNull Marker marker) {
// TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often)
marker.setIcon(getDescriptorForCluster(cluster));
marker.setTitle(getLocalizedNumber(cluster.getSize()));
}

/**
Expand Down Expand Up @@ -1176,4 +1180,9 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
marker.setPosition(position);
}
}

private String getLocalizedNumber(int number) {
NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault());
return numberFormat.format(number);
}
}
Loading

Back | FazBrowse Home | New Git URL