我正在我的 Android google-map 项目中使用 mapviewballons,但我似乎遇到了上述问题。
09-08 02:15:11.792: E/AndroidRuntime(484): FATAL EXCEPTION: main
09-08 02:15:11.792: E/AndroidRuntime(484): java.lang.NoClassDefFoundError: com.example.samplemap.CustomItemizedOverlay
我已经梳理了代码,但还没有找到这个问题的确切来源。感谢您能负担得起的任何帮助,以帮助我解决此问题。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
final MapController mc = mapView.getController();
mc.setZoom(16);
List<Overlay> mapOverlays = mapView.getOverlays();
// Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
Drawable drawable = getResources().getDrawable(R.drawable.marker);
CustomItemizedOverlay<CustomOverlayItem> itemizedoverlay = new CustomItemizedOverlay<CustomOverlayItem>(drawable, mapView);
LocalGeoPoints loc = new LocalGeoPoints();
for (CustomOverlayItem a : loc.overlayitems) {
itemizedoverlay.addOverlay(a);
}
mapOverlays.add(itemizedoverlay);
}
public class CustomItemizedOverlay<Item extends OverlayItem> extends BalloonItemizedOverlay<CustomOverlayItem> {
private ArrayList<CustomOverlayItem> m_overlays = new ArrayList<CustomOverlayItem>();
private Context c = null;
public CustomItemizedOverlay(Drawable defaultMarker, MapView mapView) {
super(boundCenter(defaultMarker), mapView);
c = mapView.getContext();
}
public void addOverlay(CustomOverlayItem overlay) {
m_overlays.add(overlay);
populate();
}
@Override
protected CustomOverlayItem createItem(int i) {
return m_overlays.get(i);
}
@Override
public int size() {
return m_overlays.size();
}
@Override
protected boolean onBalloonTap(int index, CustomOverlayItem item) {
Toast.makeText(c, "onBalloonTap for overlay index " + index,
Toast.LENGTH_LONG).show();
return true;
}
@Override
protected BalloonOverlayView<CustomOverlayItem> createBalloonOverlayView() {
// use our custom balloon view with our custom overlay item type:
return new CustomBalloonOverlayView<CustomOverlayItem>(getMapView().getContext(), getBalloonBottomOffset());
}
}