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