I was wondering what is the proper way of loading ItemizedOverlay markers from the web, use caching in some sort of a way.
Right now i'm downloading all the images and converting them to drawables, it works just fine but I want to see if there is a better way of doing this.
public class ImageLoad extends AsyncTask<String, Bitmap, Bitmap> {
private String url;
private MapView mapView;
public ImageLoad() {
}
public ImageLoad(MapView mapView) {
this.mapView = mapView;
}
protected Bitmap doInBackground(String... params) {
url = params[0];
try {
return BitmapFactory.decodeStream(new URL(url).openConnection().getInputStream());
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Override
protected void onPostExecute(Bitmap result) {
Drawable d = new BitmapDrawable(mapView.getContext().getResources(), result);
SimpleItemizedOverlay itemizedOverlay = new SimpleItemizedOverlay(d, mapView);
GeoPoint p = new GeoPoint(32061628, 34774767);
itemizedOverlay.addOverlay(new OverlayItem(p, "zzz", "zzz"));
mapView.getOverlays().add(itemizedOverlay);
mapView.invalidate();
super.onPostExecute(result);
}
}