I\'ve started to study Android few weeks ago and now I need your help. My task is create off-line map (using OSMDroid and Mobile Atlas Creator), with two markers on it, path
You need to create new class, like this:
public class MyOwnItemizedOverlay extends ItemizedIconOverlay<OverlayItem> {
protected Context mContext;
public MyOwnItemizedOverlay(final Context context, final List<OverlayItem> aList) {
super(context, aList, new OnItemGestureListener<OverlayItem>() {
@Override public boolean onItemSingleTapUp(final int index, final OverlayItem item) {
return false;
}
@Override public boolean onItemLongPress(final int index, final OverlayItem item) {
return false;
}
} );
// TODO Auto-generated constructor stub
mContext = context;
}
@Override
protected boolean onSingleTapUpHelper(final int index, final OverlayItem item, final MapView mapView) {
//Toast.makeText(mContext, "Item " + index + " has been tapped!", Toast.LENGTH_SHORT).show();
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
}
Here is how to use it in the first (main) class:
MapView mapView = new MapView(this, 256); //constructor
//some code from te question
ArrayList<OverlayItem> overlayItemArray = new ArrayList<OverlayItem>();
OverlayItem olItem = new OverlayItem("Here", "SampleDescription", new GeoPoint(54.332, 48.389));//marker
MyOwnItemizedOverlay overlay = new MyOwnItemizedOverlay(this, overlayItemArray);
mapView.getOverlays().add(overlay);
setContentView(mapView); //displaying the MapView
That's all. Good luck! links: http://code.google.com/p/osmdroid/issues/detail?id=245#makechanges