The overall approach is correct, but the details how you implemented it can be improved.
Improvement 1
In your onPostExecute()
every time you download an image you are creating a new ItemizedOverlay
object and add a single item to it. In general, is more efficient to use a unique ItemizedOverlay
and add all the items to it.
- Create
ItemizedOverlay
and add it toMapView.getOverlays().add()
before load first image - Change
ImageLoad
class to receiveItemizedOverlay
instead ofMapView
- In
onPostExecute()
create a newOverlayItem
and add it toItemizedOverlay
With this, you will have only one ItemizedOverlay
with several items in it. With your code you have several ItemizedOverlays
with one image each.
Improvement 2
You are not resizing the images that you download the Web. Unless you are sure they all have a suitable size, you should enforce the size before add them to the overlay. Otherwise, you will be using more memory and could get an image that covers all the screen and thats not what user expects.
You can resize the Bitmap
using method Bitmap.createScaledBitmap()
.
Regards.