Android Mapview: Control Ordering Of Multiple Types Of Overlayitems?
I have searched for a while on this problem but have come up trumps. I have a simple mapview that makes use of custom overlay items on a ManagedOverlay, let's call them redOverlayI
Solution 1:
Alright guys, I figured it out.
In your Overlay, you need to override getIndexToDraw
//Overriding to return add order rather than latitude order.protectedintgetIndexToDraw(int drawingOrder){
return drawingOrder;
}
Rather than call super.getIndexToDraw(int), which returns items ordered by latitude value, all I'm doing now is returning the order in which they are added. Then all I do for my array of overlays is sort them accordingly (I'm using Rob Carmick's BeanComparator, but you could use any sorting function really)
BeanComparator bc = newBeanComparator(CustomOverlayItem.class, "getIsRed");
Collections.sort(overlayItemsArray, bc);
Post a Comment for "Android Mapview: Control Ordering Of Multiple Types Of Overlayitems?"