Android MapView Overlay图像无法显示

时间:2013-07-15 14:45:10

标签: android google-maps android-mapview

我正在尝试使用Google Maps API v1(定位姜饼设备)编写一个简单的MapView

尝试按照示例hello-mapview进行操作后,图片无法在地图上显示。

有一个叠加层,因为触摸甚至可以正常工作并显示文字,但是没有任何图像与它一起出现。

有人能发现我错过的东西吗?

MyMapView.java

public class MyMapView extends MapActivity {

private MapView mapView;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = getResources().getDrawable(R.drawable.androidmarker);
    NewOverlay itemizedoverlay = new NewOverlay(drawable, this);
    GeoPoint point = new GeoPoint(19240000,-99120000);
    OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

NewOverlay.java

public class NewOverlay extends ItemizedOverlay<OverlayItem> {

private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
private Context mContext;

public NewOverlay(Drawable defaultMarker, Context context) {
    super(defaultMarker);
    mContext = context;
}

@Override
protected OverlayItem createItem(int i) {
    return mOverlays.get(i);
}

@Override
public int size() {
    return mOverlays.size();
}

public void addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();
}

public void removeOverlays(){
    mOverlays.clear();
    populate();
}

@Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}
}

0 个答案:

没有答案