我是Android开发和Java的新手,请原谅我的无知。
我在使用ItemizedOverlay向Mapnik地图添加精确定位时遇到问题。我正在关注谷歌地图教程,并试图将其转换为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);
}
答案 0 :(得分: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
}
}