Reputation: 503
Currently using ItemizedIconOverlay from OSMdroid library
import org.osmdroid.views.overlay.ItemizedIconOverlay;
And I set my parameters this way:
public class OsmActivity extends Activity implements LocationListener{
private ItemizedIconOverlay<OverlayItem> mMyLocationOverlay
...
}
And I add items this way:
mItems.add(new OverlayItem("Title 2", "Sample Description2", new GeoPoint((int)(35.1359488*1E6),(int)(33.3336289*1E6))));
mItems.add(new OverlayItem("Title 3", "Sample Description3", new GeoPoint((int)(35.1259488*1E6),(int)(33.3436289*1E6))));
this.mMyLocationOverlay = new ItemizedIconOverlay<OverlayItem>(mItems, myCustomIconMarker, new Glistener(), mResourceProxy);
Now how do I do this with this ItemizedOverlayWithFocus ?
This is what's confusing me:
ItemizedOverlayWithFocus<T extends OverlayItem> extends ItemizedOverlay<T>
What does T mean?
Can someone post example code that uses it?
Upvotes: 0
Views: 1559
Reputation: 229
haven't actually tried writing any code to back this up, but having a quick look at the code in question, you should be able to do exactly as you are doing, but substitute ItemizedIconOverlay with ItemizedOverlayWithFocus
the is all to do with generics and templating, concepts which allow us to make more type safe objects.
so where you have ItemizedIconOverlay you are saying that the internals of ItemizedIconOverlay will only ever work with OverlayItems (or subclasses thereof).
the same is applied to ItemizedOverlayWithFocus
what that's saying is that when you create your constructor (and all the item arrays etc that you put into it), the type of data you specify in the chevrons <> must be of type OverlayItem, or must extend OverlayItem.
so in theory your code could be changed to
private ItemizedOverlayWithFocus<OverlayItem> mMyLocationOverlay;
...
mItems.add....
the trick comes with the constructor, as the WithFocus class has different constructors to those you've used above you have a choice of (where this will work as long as you're in an activity class as you need a Context object)
this.mMyLocationOverlay = newItemizedOverlayWithFocus<OverlayItem>(this, mItems, new GListener());
or this.mMyLocationOverlay = newItemizedOverlayWithFocus(this, mItems, new GListener(), mResourceProxy);
or (you'll have to fill in the quoted 'blanks' on this one)
this.mMyLocationOverlay = newItemizedOverlayWithFocus<OverlayItem>(this, mItems, 'Drawable marker', 'Point markerHotspot', 'Drawable markerFocusedBase', 'Point markerFocusedHotspot', 'int focusedBackgroundColour', new GListener(), mResourceProxy);
Upvotes: 1