这是我在 GPSTracker.java 中使用ItemizedOverlay的代码:
Drawable drawable = this.getResources().getDrawable(R.drawable.red);
OverlayItem overlayItem = new OverlayItem(point, "", "");
itemizedOverlay = new MyItemizedOverlay(drawable,this);
itemizedOverlay.addOverlay(overlayItem);
mapView.getOverlays().add(itemizedOverlay);
mapView.invalidate();
这是 MyItemizedOverlay.java 的完整代码:
public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
public MyItemizedOverlay(Drawable defaultMarker, Context ctx) {
super(boundCenterBottom(defaultMarker));
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
public void clear() {
mOverlays.clear();
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
@Override
public int size() {
return mOverlays.size();
}
@Override
protected boolean onTap(int index) {
return true;
}
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView){
return false;
}}
如何修复错误?