I'm trying to show images (downloaded from a server) as map markers on a Google Map. I'm using Android-Maps-Extensions because i wasn't happy with Google Map-Utils performance.
Now i'm wondering how to load map marker images aynchronously with AME. The task is to show the image itself if it is not a cluster. If it is a cluster, i want to display the image of the first marker and the number of elements in the cluster.
Up to this point i've done the following:
1) Setup the Map Clusterer
private void setupMapClusterer() {
mClusterOptions = new EClusterOptionsProvider(getContext());
ClusteringSettings clusteringSettings = new ClusteringSettings();
clusteringSettings.addMarkersDynamically(true);
clusteringSettings.clusterOptionsProvider(mClusterOptions);
mMap.setClustering(clusteringSettings);
}
2) Create the Cluster Options Provider
public EClusterOptionsProvider(Context context) {
mClusterOptions = new ClusterOptions();
mContext = context;
mIconGenerator = new IconGenerator(context);
// Inflate Layout
View markerView = LayoutInflater.from(context).inflate(R.layout.map_marker, null);
mImageView = (ImageView) markerView.findViewById(R.id.map_marker_image);
mTextView = (TextView) markerView.findViewById(R.id.map_marker_text);
// Setup Icon Generator
mIconGenerator.setContentView(markerView);
}
public Bitmap createIcon(Bitmap bmp, String text) {
mImageView.setImageBitmap(bmp);
mTextView.setText(text);
return mIconGenerator.makeIcon();
}
@Override
public ClusterOptions getClusterOptions(List<Marker> list) {
// Get Bitmap from first marker
Marker first = list.get(0);
mClusterOptions.icon(BitmapDescriptorFactory.fromBitmap(mIconGenerator.makeIcon()));
return mClusterOptions;
}
This gives me a Map where clusters have my custom view (which is correct), but i can't figure out where to download the images and how to put them into the single markers and especially the clusters.
Of course i don't want to download all images in advance (we're talking about 500+) images.
On a sidenode: I'm using Volley to dl the images asynchronously.