I have been trying for hours to figure out why I can not use an Itemized Map overlay without doing this before adding it to the ovelays of the map:
GeoPoint po
if you make important changes on your ItemizedOverlay you have every time to do
with
private void delete_usrer_Marker_from_Overlays(MyOverlays myio){
List<Overlay> mapOverlays = mapView.getOverlays();
if (mapOverlays != null)
{
for (int i = 0;i< mapOverlays.size();i++)
{
Overlay x = mapOverlays.get(i);
if (x.hashCode() == myio.hashCode())
{
mapOverlays.remove(x);
}
}
}
}
The itemized overlay needs the 2nd 2 paramters because it uses them for click events. When you click one of the itemized overlays, it has a title and a description associated with it, which are the 2nd and 3rd parameters in your overlay item
I recently came across this problem. The issue is outlined in this bug report.
To fix it you should call populate() in your ItemizedOverlay before any data is populated. I added it to the constructor:
private class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {
private Context context;
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
LocationItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
this.context = context;
populate(); // Add this
}
}