2

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!

Palund
  • 147
  • 7

1 Answers1

2

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.

Flo
  • 27,355
  • 15
  • 87
  • 125
  • Thanks, Flo! This is a good idea! How would such a custom overlay would look like? Can you give me a hint? – Palund Jan 16 '12 at 15:58
  • You have to implement a class which inherits from Overlay class. In the class you have to override the draw method and implement the drawing for the items of you array. Check this item to get an idea how to implement a custom overlay class. http://stackoverflow.com/questions/4428730/creating-custom-overlay-on-the-map But of course you could also try the ItemizedOverlay perhaps it is fast enough. – Flo Jan 16 '12 at 16:38