我尝试使用自定义Overlay类为OSMdroid地图制作自定义标记。我在OSM中有自定义类标记。我想通过更改此标记的图标来显示聚焦标记。我该怎么办?
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import org.osmdroid.ResourceProxy;
import org.osmdroid.api.IMapView;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.overlay.ItemizedOverlay;
import org.osmdroid.views.overlay.OverlayItem;
import java.util.ArrayList;
public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {
private ArrayList<OverlayItem> overlayItemList = new ArrayList<OverlayItem>();
private Context context;
public MyItemizedOverlay(Drawable pDefaultMarker,
ResourceProxy pResourceProxy,Context context) {
super(pDefaultMarker, pResourceProxy);
this.context=context;
// TODO Auto-generated constructor stub
}
public int addItem(GeoPoint p, String title, String snippet){
OverlayItem newItem = new OverlayItem(title, snippet, p);
overlayItemList.add(newItem);
populate();
return overlayItemList.size()-1;
}
@Override
public boolean onSnapToItem(int arg0, int arg1, Point arg2, IMapView arg3) {
// TODO Auto-generated method stub
return false;
}
@Override
protected OverlayItem createItem(int arg0) {
// TODO Auto-generated method stub
return overlayItemList.get(arg0);
}
@Override
public int size() {
// TODO Auto-generated method stub
return overlayItemList.size();
}
@Override
protected boolean onTap(int index) {
OverlayItem item = overlayItemList.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
}