package dk.thoerup.traininfo.stationmap; import java.util.ArrayList; import java.util.List; import android.content.Context; import android.graphics.drawable.Drawable; import android.util.Log; import android.widget.Toast; import com.google.android.maps.ItemizedOverlay; import com.google.android.maps.OverlayItem; public class StationOverlay extends ItemizedOverlay { private ArrayList mOverlays = new ArrayList(); Context context; public StationOverlay(Drawable defaultMarker, Context ctx) { super(boundCenterBottom(defaultMarker)); context = ctx; } /* public void addUserLocation(GeoPair location, Drawable icon) { OverlayItem item = new OverlayItem(location.toGeopoint(), "You", "You"); item.setMarker(icon); mOverlays.add(item); populate(); }*/ @Override protected boolean onTap(int index) { OverlayItem item = mOverlays.get(index); Toast.makeText(context, item.getSnippet(), Toast.LENGTH_SHORT).show(); Log.e("OnTap", "OnTab:"+index); return true; } public void addStations( List stations ) { for (GeoPair gp : stations) { OverlayItem item = new OverlayItem(gp.toGeopoint(), "Station", gp.getDescription()); mOverlays.add(item); } populate(); } @Override protected OverlayItem createItem(int i) { return mOverlays.get(i); } @Override public int size() { return mOverlays.size(); } }