1

我是 Android 开发和 Java 的新手,所以请原谅我的无知。

我在使用 ItemizedOverlay 向 Mapnik 地图添加精确点时遇到问题。我正在关注 Google Maps 教程并尝试将其转换为 OSMDroid,但我无法使其正常工作。在课堂打击中,错误以红色突出显示。如果有更多经验的人能指出我哪里出错了,我将不胜感激。

ItemizedOverlay 类:

public class CustomPoint extends ItemizedOverlay<OverlayItem>{

    private ArrayList<OverlayItem> mItemList = new ArrayList<OverlayItem>();
    private Context c;

public CustomPoint(Drawable pDefaultMarker, ResourceProxy pResourceProxy) {
        super(pDefaultMarker, pResourceProxy);
        // TODO Auto-generated constructor stub
    }


    public CustomPoint(Drawable m, Context context){
        this(m);
       c = context;     
        }


   public void addOverlay(OverlayItem aOverlayItem)
    {
        mItemList.add(aOverlayItem);
        populate();
    }

    public void removeOverlay(OverlayItem aOverlayItem)
    {
        mItemList.remove(aOverlayItem);
        populate();
    }

    @Override
    protected OverlayItem createItem(int i)
    {
        return mItemList.get(i);
    }

    @Override
    public int size()
    {
        if (mItemList != null)
            return mItemList.size();
        else
            return 0;
    }

    public boolean onSnapToItem(int arg0, int arg1, Point arg2, IMapView arg3)
    {
        // TODO Auto-generated method stub
        return false;
    }

    public void insertPinpoint(OverlayItem o) {
        // TODO Auto-generated method stub
        mItemList.add(o); 
        populate();

    }

}

调用 CustomPoint 类的 MainActivity 类:

public void onClick(DialogInterface dialog, int which) {
    OverlayItem overlayItem = new OverlayItem("Here I am", "2nd String",(GeoPoint)touchedPoint);
    CustomPoint custom = new CustomPoint(d, MainActivity.this);
    custom.insertPinpoint(overlayItem);
    overlayList.add(custom);
            }
4

1 回答 1

0

你为什么不把你的类扩展到ItemizedIconOverlay

public class CustomPoint extends ItemizedIconOverlay<OverlayItem>{

    private ArrayList<OverlayItem> mItemList = new ArrayList<OverlayItem>();
    private Context c;

public CustomPoint(Master master,ArrayList<OverlayItem> pList,Drawable marker, ItemizedIconOverlay.OnItemGestureListener<OverlayItem> pOnItemGestureListener, ResourceProxy pResourceProxy) {
        super(pList, marker, pOnItemGestureListener, pResourceProxy);
        // TODO Auto-generated constructor stub
    }
}
于 2014-04-09T11:23:49.210 回答