1

私は Android 開発と Java を初めて使用するので、無知なことをお許しください。

ItemizedOverlay を使用して Mapnik マップにピンポイントを追加する際に問題が発生しています。Google マップのチュートリアルに従い、それを 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 に答える