I want to add markers to my OSMdroid map. I am using OSMdroid version 5.5. The official tutorial suggests the following code:
//your items
A
Okay, so I found out how to use it. The ItemizedOverlayWithFocus
doesn't require a ResourceProxy at all. So you can use one of the following constructors:
public ItemizedOverlayWithFocus(Context pContext, List- aList, OnItemGestureListener
- aOnItemTapListener) { ... }
public ItemizedOverlayWithFocus(List
- aList, OnItemGestureListener
- aOnItemTapListener, Context pContext) { ... }
public ItemizedOverlayWithFocus(List
- aList, Drawable pMarker, Drawable pMarkerFocused, int pFocusedBackgroundColor, OnItemGestureListener
- aOnItemTapListener, Context pContext) { ... }
This is how I adjusted the code from my question to make it work:
//your items
ArrayList items = new ArrayList();
items.add(new OverlayItem("Title", "Description", new GeoPoint(0.0d,0.0d))); // Lat/Lon decimal degrees
//the overlay
ItemizedOverlayWithFocus mOverlay = new ItemizedOverlayWithFocus(
this, items, // <--------- added Context this as first parameter
new ItemizedIconOverlay.OnItemGestureListener() {
@Override
public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
//do something
return true;
}
@Override
public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
}); // <----- removed the mResourceProxy parameter
mOverlay.setFocusItemsOnTap(true);
mMapView.getOverlays().add(mOverlay);