Search code examples
androidoverlayitemizedoverlay

Create/update map overlays from list of objects


I have an array list containing objects from the class EventOnMap. Every object has (amongs others) the member variables eventLatitude, eventLongitude and eventType. The list is updated regurlarly (e.g. objects are inserted and deleted) up to several times a second. The list is not too big, it contains at most 50 elements.

On my mapView I now would like to dynamically create and update overlays for all events depending on the list. The list represents the status of the overlays, that means I would like to update the overlay position when the coresponding longitude/latitude values change in the list.

Does anybody know a way to do this? Thanks in advance!


Solution

  • Have a look at the ItemizedOverlay class which might be better for this case than creating an overlay for every item in you array.

    The bigger problem might be you update intervals as they are really small. I don't know how the performance of an ItemizedOverlay when it gets updated so often. As you cannot edit the items on the overlay. To change the location of an item you have to remove and add it again to the ItemizedOverlay and call populate(). But this will handle all items again.

    So perhaps it is better to write one custom overlay which handles all items on you map.