1 |
torben |
368 |
package dk.thoerup.traininfo.stationmap;
|
2 |
|
|
|
3 |
|
|
import java.util.ArrayList;
|
4 |
|
|
import java.util.List;
|
5 |
|
|
|
6 |
torben |
369 |
import android.content.Context;
|
7 |
torben |
368 |
import android.graphics.drawable.Drawable;
|
8 |
|
|
import android.util.Log;
|
9 |
torben |
369 |
import android.widget.Toast;
|
10 |
torben |
368 |
|
11 |
|
|
import com.google.android.maps.ItemizedOverlay;
|
12 |
|
|
import com.google.android.maps.OverlayItem;
|
13 |
|
|
|
14 |
|
|
public class StationOverlay extends ItemizedOverlay<OverlayItem> {
|
15 |
|
|
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
|
16 |
|
|
|
17 |
torben |
369 |
Context context;
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
public StationOverlay(Drawable defaultMarker, Context ctx) {
|
21 |
torben |
368 |
super(boundCenterBottom(defaultMarker));
|
22 |
torben |
369 |
context = ctx;
|
23 |
torben |
368 |
}
|
24 |
torben |
369 |
/*
|
25 |
|
|
public void addUserLocation(GeoPair location, Drawable icon) {
|
26 |
|
|
OverlayItem item = new OverlayItem(location.toGeopoint(), "You", "You");
|
27 |
|
|
item.setMarker(icon);
|
28 |
|
|
|
29 |
torben |
368 |
mOverlays.add(item);
|
30 |
|
|
|
31 |
|
|
populate();
|
32 |
torben |
369 |
}*/
|
33 |
torben |
368 |
|
34 |
|
|
@Override
|
35 |
|
|
protected boolean onTap(int index) {
|
36 |
torben |
369 |
OverlayItem item = mOverlays.get(index);
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
Toast.makeText(context, item.getSnippet(), Toast.LENGTH_SHORT).show();
|
40 |
|
|
|
41 |
|
|
Log.e("OnTap", "OnTab:"+index);
|
42 |
|
|
return true;
|
43 |
torben |
368 |
}
|
44 |
|
|
|
45 |
|
|
public void addStations( List<GeoPair> stations ) {
|
46 |
|
|
for (GeoPair gp : stations) {
|
47 |
torben |
369 |
OverlayItem item = new OverlayItem(gp.toGeopoint(), "Station", gp.getDescription());
|
48 |
torben |
368 |
mOverlays.add(item);
|
49 |
|
|
}
|
50 |
|
|
populate();
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
@Override
|
54 |
|
|
protected OverlayItem createItem(int i) {
|
55 |
|
|
return mOverlays.get(i);
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
@Override
|
61 |
|
|
public int size() {
|
62 |
|
|
return mOverlays.size();
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
}
|