首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ItemizedOverlay OSMDroid

ItemizedOverlay OSMDroid
EN

Stack Overflow用户
提问于 2012-08-19 09:56:28
回答 1查看 1.4K关注 0票数 1

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

我在使用ItemizedOverlay向Mapnik地图添加一个精确点时遇到了问题。我正在遵循谷歌地图教程,并试图将它转换为OSMDroid,我无法让它工作。在类blow中,错误以红色突出显示。如果有更多经验的人能指出我的错误所在,我将非常感激。

ItemizedOverlay类:

代码语言:javascript
复制
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();

    }

}

MainActivity类,它调用CustomPoint类:

代码语言:javascript
复制
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);
            }
EN

回答 1

Stack Overflow用户

发布于 2014-04-09 11:23:49

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

代码语言:javascript
复制
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
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12025639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档